-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support Eslint 7 & add rules #15
Changes from all commits
abd5b3d
e0e33d4
d44cec5
0ada918
90568b4
2f3fa09
3d4e63b
81e002a
eb56be7
5ba8acb
de32f93
cc03c02
1ed29e2
108abf0
cd4f9af
12689b6
3f4c2c1
d353749
3c7c575
a46b862
2206a9b
405fcae
a223833
2424c1c
fb718af
2427366
833c392
cd6f942
cc49768
eeb2040
ef3bf96
1e102c1
70bdcdd
00b2789
8f4b52c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "./base.js" | ||
"extends": "./script.js" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
node_modules/ | ||
|
||
yarn.lock | ||
.npmrc |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,23 +15,35 @@ module.exports = { | |
'flowtype/delimiter-dangle': ['error', 'always-multiline', 'always-multiline', 'always-multiline'], | ||
'flowtype/generic-spacing': ['error', 'never'], | ||
'flowtype/newline-after-flow-annotation': ['error', 'always'], | ||
'flowtype/object-type-delimiter': ['error', 'comma'], | ||
'flowtype/no-existential-type': 'error', | ||
'flowtype/no-flow-fix-me-comments': 'off', | ||
'flowtype/no-mixed': 'off', | ||
'flowtype/no-dupe-keys': 'error', | ||
'flowtype/no-mutable-array': '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. I'm not sure if it forces us to only use https://github.com/gajus/eslint-plugin-flowtype/blob/master/.README/rules/no-mutable-array.md 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. We have this
And also we will still be able to do perf optimisations using |
||
'flowtype/no-primitive-constructor-types': 'error', | ||
'flowtype/no-types-missing-file-annotation': 'error', | ||
'flowtype/no-unused-expressions': 'error', | ||
// TODO: disable any? | ||
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.
|
||
'flowtype/no-weak-types': ['error', { any: false }], | ||
'flowtype/object-type-delimiter': ['error', 'comma'], | ||
'flowtype/require-compound-type-alias': ['off', 'always'], | ||
'flowtype/require-exact-type': 'off', | ||
'flowtype/require-indexer-name': 'off', | ||
'flowtype/require-inexact-type': 'off', | ||
'flowtype/require-parameter-type': 'off', | ||
'flowtype/require-readonly-react-props': 'off', | ||
'flowtype/require-readonly-react-props': 'error', | ||
'flowtype/require-return-type': 'off', | ||
'flowtype/require-types-at-top': 'off', | ||
'flowtype/require-valid-file-annotation': 'off', | ||
'flowtype/sort-keys': ['error', 'asc', { caseSensitive: false, natural: true }], | ||
'flowtype/require-variable-type': 'off', | ||
'flowtype/semi': ['error', 'always'], | ||
'flowtype/sort-keys': ['error', 'asc'], | ||
'flowtype/space-after-type-colon': ['error', 'always'], | ||
'flowtype/space-before-generic-bracket': ['error', 'never'], | ||
'flowtype/space-before-type-colon': ['error', 'never'], | ||
'flowtype/spread-exact-type': '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. 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's because spreading non-exact type is not safe and not properly supported by flow 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. Might be possible to enable 🤔 |
||
'flowtype/type-id-match': 'off', | ||
// Use identifier as declaration imports are not well supported by vscode | ||
'flowtype/type-import-style': ['off', 'declaration'], | ||
'flowtype/union-intersection-spacing': ['error', 'always'], | ||
'flowtype/use-flow-type': 'warn', | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,9 +129,8 @@ module.exports = { | |
'import/no-duplicates': 'error', | ||
|
||
// disallow namespace imports | ||
// TODO: enable? | ||
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md | ||
'import/no-namespace': 'off', | ||
'import/no-namespace': 'error', | ||
|
||
// Ensure consistent use of file extension within the import path | ||
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md | ||
|
@@ -143,11 +142,30 @@ module.exports = { | |
|
||
// ensure absolute imports are above relative imports and that unassigned imports are ignored | ||
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md | ||
// TODO: enforce a stricter convention in module import order? | ||
'import/order': [ | ||
'error', { | ||
'groups': [['builtin', 'external', 'internal']], | ||
'groups': [ | ||
['builtin'], | ||
['external'], | ||
['internal'], | ||
['parent'], | ||
['sibling'], | ||
], | ||
'newlines-between': 'never', | ||
'alphabetize': { | ||
order: 'asc', | ||
caseInsensitive: true, | ||
}, | ||
'pathGroups': [ | ||
{ | ||
pattern: '$*/**', | ||
group: 'internal', | ||
}, | ||
{ | ||
pattern: '$*', | ||
group: 'internal', | ||
}, | ||
], | ||
}, | ||
], | ||
|
||
|
@@ -195,33 +213,32 @@ module.exports = { | |
// Prevent unassigned imports | ||
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md | ||
// importing for side effects is perfectly acceptable, if you need side effects. | ||
'import/no-unassigned-import': 'off', | ||
'import/no-unassigned-import': 'error', | ||
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. Not sure will it affect 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. We will have to use |
||
|
||
// Prevent importing the default as if it were named | ||
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md | ||
'import/no-named-default': 'error', | ||
|
||
// Reports if a module's default export is unnamed | ||
// https://github.com/benmosher/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md | ||
'import/no-anonymous-default-export': ['off', { | ||
allowArray: false, | ||
'import/no-anonymous-default-export': ['error', { | ||
allowArray: true, | ||
allowArrowFunction: false, | ||
allowAnonymousClass: false, | ||
allowAnonymousFunction: false, | ||
allowLiteral: false, | ||
allowObject: false, | ||
allowLiteral: true, | ||
allowObject: true, | ||
}], | ||
|
||
// This rule enforces that all exports are declared at the bottom of the file. | ||
// https://github.com/benmosher/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md | ||
// TODO: enable? | ||
'import/exports-last': 'off', | ||
'import/exports-last': 'error', | ||
|
||
// Reports when named exports are not grouped together in a single export declaration | ||
// or when multiple assignments to CommonJS module.exports or exports object are present | ||
// in a single file. | ||
// https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md | ||
'import/group-exports': 'off', | ||
'import/group-exports': 'error', | ||
Comment on lines
+235
to
+241
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. Is it when these two rules Cause I'm not sure about
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. Yeah but it's easier when navigating. If you need to add export a function then it will be grouped in last statement like
|
||
|
||
// forbid default exports. this is a terrible rule, do not use it. | ||
// https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md | ||
|
@@ -237,7 +254,7 @@ module.exports = { | |
|
||
// Forbid cyclical dependencies between modules | ||
// https://github.com/benmosher/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md | ||
'import/no-cycle': ['error', { maxDepth: Infinity }], | ||
'import/no-cycle': ['error', { ignoreExternal: true, maxDepth: Infinity }], | ||
|
||
// Ensures that there are no useless path segments | ||
// https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md | ||
|
@@ -256,9 +273,7 @@ module.exports = { | |
|
||
// Reports modules without any exports, or with unused exports | ||
// https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md | ||
// TODO: enable, semver-major | ||
'import/no-unused-modules': ['off', { | ||
ignoreExports: [], | ||
missingExports: true, | ||
unusedExports: true, | ||
}], | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,13 @@ module.exports = { | |
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-dom-props.md | ||
'react/forbid-dom-props': ['off', { forbid: [] }], | ||
|
||
// Enforce a specific function type for function components. | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/v7.20.0/docs/rules/function-component-definition.md | ||
'react/function-component-definition': ['error', { | ||
namedComponents: 'function-declaration', | ||
unnamedComponents: 'function-expression', | ||
}], | ||
|
||
// Enforce boolean attributes notation in JSX | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md | ||
'react/jsx-boolean-value': ['error', 'never', { always: [] }], | ||
|
@@ -82,7 +89,7 @@ module.exports = { | |
|
||
// Validate JSX has key prop when in array or iterator | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md | ||
'react/jsx-key': 'off', | ||
'react/jsx-key': ['error', { checkFragmentShorthand: true }], | ||
|
||
// Limit maximum of props on a single line in JSX | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md | ||
|
@@ -177,7 +184,7 @@ module.exports = { | |
|
||
// Prevent direct mutation of this.state | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md | ||
'react/no-direct-mutation-state': 'off', | ||
'react/no-direct-mutation-state': 'error', | ||
|
||
// Prevent usage of isMounted | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md | ||
|
@@ -300,7 +307,7 @@ module.exports = { | |
|
||
// Enforce JSX indentation | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md | ||
'react/jsx-indent': ['error', 2], | ||
'react/jsx-indent': ['error', 2, { indentLogicalExpressions: true, checkAttributes: true }], | ||
|
||
// Disallow target="_blank" on links | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-no-target-blank.md | ||
|
@@ -476,12 +483,10 @@ module.exports = { | |
|
||
// Enforce state initialization style | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md | ||
// TODO: set to "never" once babel-preset-airbnb supports public class fields | ||
'react/state-in-constructor': ['off', 'never'], | ||
'react/state-in-constructor': ['error', 'never'], | ||
|
||
// Enforces where React component static properties should be positioned | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md | ||
// TODO: set to "static public field" once babel-preset-airbnb supports public class fields | ||
'react/static-property-placement': ['error', 'static public field'], | ||
|
||
// Disallow JSX props spreading | ||
|
@@ -494,7 +499,7 @@ module.exports = { | |
|
||
// Enforce that props are read-only | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md | ||
'react/prefer-read-only-props': 'off', | ||
'react/prefer-read-only-props': 'error', | ||
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. This might lead to a lot of changes but I think is most likely simple fixes. Not sure if it would be too verbose though. 🤔 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 I'll enable them one-by-one to have separated commits |
||
}, | ||
|
||
settings: { | ||
|
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.
Missing breaking changes
eslint
to^7.10.0
.