New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update dependencies and lint #2391
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ | |
"shorten-repo-url": "^1.5.2", | ||
"tiny-version-compare": "^1.0.0", | ||
"webext-additional-permissions": "^0.1.0", | ||
"webext-detect-page": "^1.0.2", | ||
"webext-detect-page": "^1.0.3", | ||
"webext-domain-permission-toggle": "^1.0.0", | ||
"webext-dynamic-content-scripts": "^6.0.3", | ||
"webext-options-sync": "^1.0.0-8", | ||
|
@@ -51,41 +51,41 @@ | |
}, | ||
"devDependencies": { | ||
"@sindresorhus/tsconfig": "^0.4.0", | ||
"@types/chrome": "0.0.86", | ||
"@types/chrome": "0.0.88", | ||
"@types/codemirror": "0.0.76", | ||
"@types/copy-webpack-plugin": "^5.0.0", | ||
"@types/firefox-webext-browser": "^67.0.2", | ||
"@types/jsdom": "^12.2.4", | ||
"@types/mini-css-extract-plugin": "^0.2.1", | ||
"@types/react": "^16.8.23", | ||
"@types/mini-css-extract-plugin": "^0.8.0", | ||
"@types/react": "^16.9.2", | ||
"@types/terser-webpack-plugin": "^1.2.1", | ||
"@typescript-eslint/eslint-plugin": "^1.11.0", | ||
"@typescript-eslint/parser": "^1.11.0", | ||
"ava": "^2.2.0", | ||
"@typescript-eslint/eslint-plugin": "^1.13.0", | ||
"@typescript-eslint/parser": "^1.13.0", | ||
"ava": "^2.3.0", | ||
"chrome-webstore-upload-cli": "^1.2.0", | ||
"copy-webpack-plugin": "^5.0.3", | ||
"css-loader": "^3.0.0", | ||
"copy-webpack-plugin": "^5.0.4", | ||
"css-loader": "^3.2.0", | ||
"daily-version": "^0.12.0", | ||
"dot-json": "^1.0.4", | ||
"eslint": "^6.0.1", | ||
"eslint-config-xo-typescript": "^0.15.0", | ||
"fork-ts-checker-webpack-plugin": "^1.3.7", | ||
"eslint": "^6.2.2", | ||
"eslint-config-xo-typescript": "^0.16.0", | ||
"fork-ts-checker-webpack-plugin": "^1.5.0", | ||
"jsdom": "^15.1.1", | ||
"mini-css-extract-plugin": "^0.7.0", | ||
"mini-css-extract-plugin": "^0.8.0", | ||
"npm-run-all": "^4.1.3", | ||
"size-plugin": "^1.2.0", | ||
"size-plugin": "^2.0.0", | ||
"string-replace-loader": "^2.2.0", | ||
"stylelint": "^10.1.0", | ||
"stylelint-config-xo": "^0.15.0", | ||
"terser-webpack-plugin": "^1.3.0", | ||
"terser-webpack-plugin": "^1.4.1", | ||
"ts-loader": "^6.0.4", | ||
"ts-node": "^8.3.0", | ||
"type-fest": "^0.6.0", | ||
"typescript": "^3.5.3", | ||
"type-fest": "^0.7.1", | ||
"typescript": "^3.6.2", | ||
"web-ext": "^3.1.1", | ||
"web-ext-submit": "^3.1.1", | ||
"webpack": "^4.35.3", | ||
"webpack-cli": "^3.3.5", | ||
"webpack": "^4.39.3", | ||
"webpack-cli": "^3.3.7", | ||
"xo": "^0.24.0" | ||
}, | ||
"xo": { | ||
|
@@ -105,13 +105,17 @@ | |
"rules": { | ||
"no-alert": "off", | ||
"import/no-unassigned-import": "off", | ||
"import/no-unresolved": "warn" | ||
"import/no-unresolved": "warn", | ||
"import/named": "warn" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That rule has other problems too. Disabled: xojs/xo@ee145cb |
||
}, | ||
"overrides": [ | ||
{ | ||
"files": "**/*.+(ts|tsx)", | ||
"extends": "xo-typescript", | ||
"rules": { | ||
"@typescript-eslint/no-misused-promises": "off", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Annoying: It doesn't let us use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While it's convenient, my reasoning is that using async there makes it hard to see that the event handler function will cause an uncaught rejection if the And when people see: [1, 2, 3].forEach(async value => {
await doSomething(value);
}); they might be fooled into thinking that it awaits for each iteration, which it does not. I'm happy to discuss this though. Maybe there some additional config that could be added to the rule? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand the value in that case, but I don't have a solution for our use-case: our handlers are If we enable this rule, we have to write listeners as: function handler() {
(async () => {
document.body.append(await fetchDom(...));
})();
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A more useful related rule would be the opposite: always await async functions. Does this exist already? async function set(){...}
async function get(){...}
set(1); // Forgot `await`
await get(); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Almost, |
||
"@typescript-eslint/promise-function-async": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good in theory, but makes us have to type one-off things just for the heck of it:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea was that you explicitly disable the rule where you want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Maybe that is worth it, I missed this one just recently: https://github.com/sindresorhus/refined-github/pull/2393/files#diff-f8fed5d366f31fce028a9c8ceca38c3eR6 The lines in my examples would just have to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it will be easier to enable in a year or so when TS has matured more and we need less There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What other problems have you had? Do you think there will ever be a solution to my examples? They basically are:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had problems with some bad types from Electron and React. Basically out of my control. I also had to use In the future, there will be less globals, and the types of large projects will be better, TS will be better. |
||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// TODO: Drop some definitions when their related bugs are resolved | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I merged all of these TODOs into one. They're just noise since we can only wait for the underlying bugs to be fixed. |
||
|
||
type AnyObject = Record<string, any>; | ||
type AsyncVoidFunction = () => Promise<void>; | ||
|
||
|
@@ -17,16 +19,15 @@ interface Window { | |
content: GlobalFetch; | ||
} | ||
|
||
// TODO: Drop after https://github.com/sindresorhus/p-memoize/issues/9 | ||
// Drop after https://github.com/sindresorhus/p-memoize/issues/9 | ||
declare module 'mem' { | ||
function mem<T = VoidFunction>(fn: T, options?: AnyObject): T; | ||
export = mem; | ||
} | ||
|
||
declare module 'size-plugin'; | ||
|
||
// TODO: Drop linkify-* types when Firefox adds RegEx lookbehind support | ||
// https://github.com/sindresorhus/refined-github/pull/1936#discussion_r276515991 | ||
// Drop when Firefox adds RegEx lookbehind support https://github.com/sindresorhus/refined-github/pull/1936#discussion_r276515991 | ||
declare module 'linkify-urls' { | ||
type Options = { | ||
user: string; | ||
|
@@ -44,6 +45,7 @@ declare module 'linkify-urls' { | |
export = linkifyUrls; | ||
} | ||
|
||
// Drop when Firefox adds RegEx lookbehind support https://github.com/sindresorhus/refined-github/pull/1936#discussion_r276515991 | ||
declare module 'linkify-issues' { | ||
type Options = { | ||
user: string; | ||
|
@@ -64,7 +66,6 @@ declare module 'linkify-issues' { | |
// Custom UI events specific to RGH | ||
interface GlobalEventHandlersEventMap { | ||
'details:toggled': CustomEvent; | ||
'focusin': UIEvent; // Drop when it reaches W3C Recommendation https://github.com/Microsoft/TSJS-lib-generator/pull/369 | ||
'rgh:view-markdown-source': CustomEvent; | ||
'rgh:view-markdown-rendered': CustomEvent; | ||
'filterable:change': CustomEvent; | ||
|
@@ -84,18 +85,12 @@ declare namespace JSX { | |
} | ||
} | ||
|
||
// TODO: Drop when this bug is fixed | ||
// https://github.com/Microsoft/TypeScript/issues/30928 | ||
// Drop after https://github.com/Microsoft/TypeScript/issues/30928 | ||
interface NamedNodeMap { | ||
[key: string]: Attr; | ||
} | ||
|
||
// https://github.com/Microsoft/TypeScript/issues/30928 | ||
// Drop after https://github.com/Microsoft/TypeScript/issues/30928 | ||
interface HTMLFormControlsCollection { | ||
[key: string]: HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement; | ||
} | ||
|
||
// TODO: Drop when this appears on npm https://github.com/microsoft/TypeScript/blob/340f81035ff1d753e6a1f0fedc2323d169c86cc6/src/lib/dom.generated.d.ts#L9686 | ||
interface KeyboardEvent { | ||
readonly isComposing: boolean; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm temporarily avoiding v2 because of a bug I don't know how to work around: typescript-eslint/typescript-eslint#890
They should go away by adding
test
in tsconfig'sincludes
, but that file appears to be ignored.Also reported in xojs/eslint-config-xo-typescript#15