@mrpalmer/eslint-config 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configs/base.js +233 -0
- package/configs/jest.js +101 -0
- package/configs/react.js +154 -0
- package/configs/typescript.js +150 -0
- package/index.js +19 -425
- package/package.json +38 -24
- package/utils/packageJson.js +41 -0
- package/import.js +0 -72
- package/jest.js +0 -150
- package/jsx-a11y.js +0 -48
- package/react.js +0 -139
package/jest.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
const readPkgUp = require('read-pkg-up')
|
|
2
|
-
|
|
3
|
-
let hasJestDom = false
|
|
4
|
-
let hasTestingLibrary = false
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
const { packageJson } = readPkgUp.sync({ normalize: true })
|
|
8
|
-
const allDeps = Object.keys({
|
|
9
|
-
...packageJson.peerDependencies,
|
|
10
|
-
...packageJson.devDependencies,
|
|
11
|
-
...packageJson.dependencies,
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
hasJestDom = allDeps.includes('@testing-library/jest-dom')
|
|
15
|
-
hasTestingLibrary = ['@testing-library/dom', '@testing-library/react'].some(
|
|
16
|
-
(dependency) => allDeps.includes(dependency)
|
|
17
|
-
)
|
|
18
|
-
} catch (error) {
|
|
19
|
-
// ignore error
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const rules = {
|
|
23
|
-
'react/display-name': 'off', // we don't need a display name in test files
|
|
24
|
-
|
|
25
|
-
'jest/consistent-test-it': 'off',
|
|
26
|
-
'jest/expect-expect': 'off',
|
|
27
|
-
'jest/max-nested-describe': 'error',
|
|
28
|
-
'jest/no-alias-methods': 'off',
|
|
29
|
-
'jest/no-commented-out-tests': 'warn',
|
|
30
|
-
'jest/no-conditional-expect': 'error',
|
|
31
|
-
'jest/no-deprecated-functions': 'error',
|
|
32
|
-
'jest/no-disabled-tests': 'warn',
|
|
33
|
-
'jest/no-done-callback': 'error',
|
|
34
|
-
'jest/no-duplicate-hooks': 'off',
|
|
35
|
-
'jest/no-export': 'error',
|
|
36
|
-
'jest/no-focused-tests': 'error',
|
|
37
|
-
'jest/no-hooks': 'off',
|
|
38
|
-
'jest/no-identical-title': 'error',
|
|
39
|
-
'jest/no-if': 'error',
|
|
40
|
-
'jest/no-interpolation-in-snapshots': 'error',
|
|
41
|
-
'jest/no-jasmine-globals': 'off',
|
|
42
|
-
'jest/no-jest-import': 'error',
|
|
43
|
-
'jest/no-large-snapshots': ['warn', { maxSize: 300 }],
|
|
44
|
-
'jest/no-mocks-import': 'error',
|
|
45
|
-
'jest/no-restricted-matchers': 'off',
|
|
46
|
-
'jest/no-standalone-expect': 'off',
|
|
47
|
-
'jest/no-test-prefixes': 'error',
|
|
48
|
-
'jest/no-test-return-statement': 'off',
|
|
49
|
-
'jest/prefer-called-with': 'error',
|
|
50
|
-
'jest/prefer-expect-assertions': 'off',
|
|
51
|
-
'jest/prefer-expect-resolves': 'off',
|
|
52
|
-
'jest/prefer-hooks-on-top': 'error',
|
|
53
|
-
'jest/prefer-lowercase-title': 'off',
|
|
54
|
-
'jest/prefer-spy-on': 'off',
|
|
55
|
-
'jest/prefer-strict-equal': 'off',
|
|
56
|
-
'jest/prefer-to-be': 'off',
|
|
57
|
-
'jest/prefer-to-contain': 'warn',
|
|
58
|
-
'jest/prefer-to-have-length': 'warn',
|
|
59
|
-
'jest/prefer-todo': 'warn',
|
|
60
|
-
'jest/require-hook': 'off',
|
|
61
|
-
'jest/require-to-throw-message': 'off',
|
|
62
|
-
'jest/require-top-level-describe': 'off',
|
|
63
|
-
'jest/unbound-method': 'off',
|
|
64
|
-
'jest/valid-describe-callback': 'error',
|
|
65
|
-
'jest/valid-expect': 'error',
|
|
66
|
-
'jest/valid-expect-in-promise': 'error',
|
|
67
|
-
'jest/valid-title': 'warn',
|
|
68
|
-
|
|
69
|
-
...(hasJestDom
|
|
70
|
-
? {
|
|
71
|
-
'jest-dom/prefer-checked': 'error',
|
|
72
|
-
'jest-dom/prefer-empty': 'error',
|
|
73
|
-
'jest-dom/prefer-enabled-disabled': 'error',
|
|
74
|
-
'jest-dom/prefer-focus': 'error',
|
|
75
|
-
'jest-dom/prefer-in-document': 'error',
|
|
76
|
-
'jest-dom/prefer-required': 'error',
|
|
77
|
-
'jest-dom/prefer-to-have-attribute': 'error',
|
|
78
|
-
'jest-dom/prefer-to-have-class': 'error',
|
|
79
|
-
'jest-dom/prefer-to-have-style': 'error',
|
|
80
|
-
'jest-dom/prefer-to-have-text-content': 'error',
|
|
81
|
-
'jest-dom/prefer-to-have-value': 'error',
|
|
82
|
-
}
|
|
83
|
-
: null),
|
|
84
|
-
|
|
85
|
-
...(hasTestingLibrary
|
|
86
|
-
? {
|
|
87
|
-
'testing-library/await-async-query': 'error',
|
|
88
|
-
'testing-library/await-async-utils': 'error',
|
|
89
|
-
'testing-library/await-fire-event': 'off',
|
|
90
|
-
'testing-library/consistent-data-testid': 'off',
|
|
91
|
-
'testing-library/no-await-sync-events': 'error',
|
|
92
|
-
'testing-library/no-await-sync-query': 'error',
|
|
93
|
-
'testing-library/no-container': 'error',
|
|
94
|
-
'testing-library/no-debugging-utils': 'error',
|
|
95
|
-
'testing-library/no-dom-import': ['error', 'react'],
|
|
96
|
-
'testing-library/no-manual-cleanup': 'error',
|
|
97
|
-
'testing-library/no-node-access': 'error',
|
|
98
|
-
'testing-library/no-promise-in-fire-event': 'error',
|
|
99
|
-
'testing-library/no-render-in-setup': 'error',
|
|
100
|
-
'testing-library/no-unnecessary-act': 'error',
|
|
101
|
-
'testing-library/no-wait-for-empty-callback': 'error',
|
|
102
|
-
'testing-library/no-wait-for-multiple-assertions': 'error',
|
|
103
|
-
'testing-library/no-wait-for-side-effects': 'error',
|
|
104
|
-
'testing-library/no-wait-for-snapshot': 'error',
|
|
105
|
-
'testing-library/prefer-explicit-assert': 'warn',
|
|
106
|
-
'testing-library/prefer-find-by': 'error',
|
|
107
|
-
'testing-library/prefer-presence-queries': 'error',
|
|
108
|
-
'testing-library/prefer-query-by-disappearance': 'error',
|
|
109
|
-
'testing-library/prefer-screen-queries': 'error',
|
|
110
|
-
'testing-library/prefer-user-event': 'error',
|
|
111
|
-
'testing-library/prefer-wait-for': 'error',
|
|
112
|
-
'testing-library/render-result-naming-convention': 'error',
|
|
113
|
-
}
|
|
114
|
-
: null),
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
module.exports = {
|
|
118
|
-
env: {
|
|
119
|
-
'jest/globals': true,
|
|
120
|
-
},
|
|
121
|
-
plugins: [
|
|
122
|
-
'jest',
|
|
123
|
-
hasJestDom && 'jest-dom',
|
|
124
|
-
hasTestingLibrary && 'testing-library',
|
|
125
|
-
].filter(Boolean),
|
|
126
|
-
rules: disableAll(rules),
|
|
127
|
-
overrides: [
|
|
128
|
-
{
|
|
129
|
-
files: [
|
|
130
|
-
'**/__tests__/**/*.+(js|ts)?(x)',
|
|
131
|
-
'**/*.{spec,test}.+(js|ts)?(x)',
|
|
132
|
-
],
|
|
133
|
-
rules,
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
files: ['**/__tests__/**/*.ts?(x)', '**/*.{spec,test}.ts?(x)'],
|
|
137
|
-
rules: {
|
|
138
|
-
'@typescript-eslint/unbound-method': 'off',
|
|
139
|
-
'jest/unbound-method': 'error',
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function disableAll(obj) {
|
|
146
|
-
return Object.keys(obj).reduce((rules, rule) => {
|
|
147
|
-
rules[rule] = 'off'
|
|
148
|
-
return rules
|
|
149
|
-
}, {})
|
|
150
|
-
}
|
package/jsx-a11y.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
browser: true,
|
|
4
|
-
},
|
|
5
|
-
parserOptions: {
|
|
6
|
-
ecmaFeatures: {
|
|
7
|
-
jsx: true,
|
|
8
|
-
},
|
|
9
|
-
},
|
|
10
|
-
plugins: ['jsx-a11y'],
|
|
11
|
-
rules: {
|
|
12
|
-
'jsx-a11y/accessible-emoji': 'error',
|
|
13
|
-
'jsx-a11y/alt-text': 'warn',
|
|
14
|
-
'jsx-a11y/anchor-has-content': 'error',
|
|
15
|
-
'jsx-a11y/anchor-is-valid': 'error',
|
|
16
|
-
'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
|
|
17
|
-
'jsx-a11y/aria-props': 'error',
|
|
18
|
-
'jsx-a11y/aria-proptypes': 'error',
|
|
19
|
-
'jsx-a11y/aria-role': 'error',
|
|
20
|
-
'jsx-a11y/aria-unsupported-elements': 'error',
|
|
21
|
-
'jsx-a11y/autocomplete-valid': 'error',
|
|
22
|
-
'jsx-a11y/click-events-have-key-events': 'error',
|
|
23
|
-
'jsx-a11y/control-has-associated-label': 'off',
|
|
24
|
-
'jsx-a11y/heading-has-content': 'error',
|
|
25
|
-
'jsx-a11y/html-has-lang': 'error',
|
|
26
|
-
'jsx-a11y/iframe-has-title': 'error',
|
|
27
|
-
'jsx-a11y/img-redundant-alt': 'error',
|
|
28
|
-
'jsx-a11y/interactive-supports-focus': 'warn',
|
|
29
|
-
'jsx-a11y/label-has-associated-control': 'error',
|
|
30
|
-
'jsx-a11y/lang': 'error',
|
|
31
|
-
'jsx-a11y/media-has-caption': 'warn',
|
|
32
|
-
'jsx-a11y/mouse-events-have-key-events': 'error',
|
|
33
|
-
'jsx-a11y/no-access-key': 'error',
|
|
34
|
-
'jsx-a11y/no-autofocus': 'off',
|
|
35
|
-
'jsx-a11y/no-distracting-elements': 'error',
|
|
36
|
-
'jsx-a11y/no-interactive-element-to-noninteractive-role': 'warn',
|
|
37
|
-
'jsx-a11y/no-noninteractive-element-interactions': 'warn',
|
|
38
|
-
'jsx-a11y/no-noninteractive-element-to-interactive-role': 'warn',
|
|
39
|
-
'jsx-a11y/no-noninteractive-tabindex': 'off',
|
|
40
|
-
'jsx-a11y/no-onchange': 'off',
|
|
41
|
-
'jsx-a11y/no-redundant-roles': 'error',
|
|
42
|
-
'jsx-a11y/no-static-element-interactions': 'off',
|
|
43
|
-
'jsx-a11y/role-has-required-aria-props': 'error',
|
|
44
|
-
'jsx-a11y/role-supports-aria-props': 'error',
|
|
45
|
-
'jsx-a11y/scope': 'error',
|
|
46
|
-
'jsx-a11y/tabindex-no-positive': 'warn',
|
|
47
|
-
},
|
|
48
|
-
}
|
package/react.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
const readPkgUp = require('read-pkg-up')
|
|
2
|
-
const semver = require('semver')
|
|
3
|
-
|
|
4
|
-
let oldestSupportedReactVersion = '16.5.2'
|
|
5
|
-
|
|
6
|
-
let hasPropTypes = false
|
|
7
|
-
try {
|
|
8
|
-
const pkg = readPkgUp.sync({ normalize: true })
|
|
9
|
-
// eslint-disable-next-line prefer-object-spread
|
|
10
|
-
const allDeps = Object.assign(
|
|
11
|
-
{ react: '16.5.2' },
|
|
12
|
-
pkg.peerDependencies,
|
|
13
|
-
pkg.devDependencies,
|
|
14
|
-
pkg.dependencies
|
|
15
|
-
)
|
|
16
|
-
hasPropTypes = allDeps.hasOwnProp('prop-types')
|
|
17
|
-
oldestSupportedReactVersion = semver
|
|
18
|
-
.validRange(allDeps.react)
|
|
19
|
-
.replace(/[>=<|]/g, ' ')
|
|
20
|
-
.split(' ')
|
|
21
|
-
.filter(Boolean)
|
|
22
|
-
.sort(semver.compare)[0]
|
|
23
|
-
} catch (error) {
|
|
24
|
-
// ignore error
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
module.exports = {
|
|
28
|
-
env: {
|
|
29
|
-
browser: true,
|
|
30
|
-
},
|
|
31
|
-
parserOptions: {
|
|
32
|
-
ecmaFeatures: {
|
|
33
|
-
jsx: true,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
plugins: ['react', 'react-hooks'],
|
|
37
|
-
extends: ['plugin:react-hooks/recommended'],
|
|
38
|
-
settings: {
|
|
39
|
-
react: {
|
|
40
|
-
version: oldestSupportedReactVersion,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
rules: {
|
|
44
|
-
'react/boolean-prop-naming': 'off',
|
|
45
|
-
'react/button-has-type': 'off',
|
|
46
|
-
'react/default-props-match-prop-types': hasPropTypes ? 'error' : 'off',
|
|
47
|
-
'react/destructuring-assignment': 'off',
|
|
48
|
-
'react/display-name': ['error', { ignoreTranspilerName: false }],
|
|
49
|
-
'react/forbid-component-props': 'off',
|
|
50
|
-
'react/forbid-dom-props': 'off',
|
|
51
|
-
'react/forbid-elements': 'off',
|
|
52
|
-
'react/forbid-foreign-prop-types': hasPropTypes ? 'error' : 'off',
|
|
53
|
-
'react/forbid-prop-types': 'off',
|
|
54
|
-
'react/function-component-definition': 'off',
|
|
55
|
-
'react/jsx-boolean-value': 'off',
|
|
56
|
-
'react/jsx-curly-brace-presence': [
|
|
57
|
-
'warn',
|
|
58
|
-
{ children: 'ignore', props: 'never' },
|
|
59
|
-
],
|
|
60
|
-
'react/jsx-filename-extension': ['error', { extensions: ['.js'] }],
|
|
61
|
-
'react/jsx-fragments': 'off',
|
|
62
|
-
'react/jsx-handler-names': 'off',
|
|
63
|
-
'react/jsx-key': 'error',
|
|
64
|
-
'react/jsx-max-depth': 'off',
|
|
65
|
-
'react/jsx-no-bind': 'off',
|
|
66
|
-
'react/jsx-no-comment-textnodes': 'error',
|
|
67
|
-
'react/jsx-no-constructed-context-values': 'off',
|
|
68
|
-
'react/jsx-no-duplicate-props': 'error',
|
|
69
|
-
'react/jsx-no-literals': 'off',
|
|
70
|
-
'react/jsx-no-script-url': 'error',
|
|
71
|
-
'react/jsx-no-target-blank': 'error',
|
|
72
|
-
'react/jsx-no-undef': 'error',
|
|
73
|
-
'react/jsx-no-useless-fragment': 'warn',
|
|
74
|
-
'react/jsx-pascal-case': 'error',
|
|
75
|
-
'react/jsx-props-no-spreading': 'off',
|
|
76
|
-
'react/jsx-sort-default-props': 'off',
|
|
77
|
-
'react/jsx-sort-props': 'off',
|
|
78
|
-
'react/jsx-uses-react': 'error',
|
|
79
|
-
'react/jsx-uses-vars': 'error',
|
|
80
|
-
'react/no-access-state-in-setstate': 'error',
|
|
81
|
-
'react/no-adjacent-inline-elements': 'off',
|
|
82
|
-
'react/no-array-index-key': 'off', // sometimes you don't care about the issues, or they don't apply
|
|
83
|
-
'react/no-arrow-function-lifecycle': 'error',
|
|
84
|
-
'react/no-children-prop': 'off',
|
|
85
|
-
'react/no-danger': 'off',
|
|
86
|
-
'react/no-danger-with-children': 'error',
|
|
87
|
-
'react/no-deprecated': 'error',
|
|
88
|
-
'react/no-did-mount-set-state': 'error',
|
|
89
|
-
'react/no-did-update-set-state': 'error',
|
|
90
|
-
'react/no-direct-mutation-state': 'error',
|
|
91
|
-
'react/no-find-dom-node': 'error',
|
|
92
|
-
'react/no-invalid-html-attribute': 'error',
|
|
93
|
-
'react/no-is-mounted': 'error',
|
|
94
|
-
'react/no-multi-comp': 'off',
|
|
95
|
-
'react/no-namespace': 'error',
|
|
96
|
-
'react/no-redundant-should-component-update': 'error',
|
|
97
|
-
'react/no-render-return-value': 'error',
|
|
98
|
-
'react/no-set-state': 'off',
|
|
99
|
-
'react/no-string-refs': 'error',
|
|
100
|
-
'react/no-this-in-sfc': 'error',
|
|
101
|
-
'react/no-typos': 'error',
|
|
102
|
-
'react/no-unescaped-entities': 'warn',
|
|
103
|
-
'react/no-unknown-property': 'error',
|
|
104
|
-
'react/no-unsafe': 'warn', // if you need it there should be a comment explaining why
|
|
105
|
-
'react/no-unstable-nested-components': ['error', { allowAsProps: true }],
|
|
106
|
-
'react/no-unused-class-component-methods': 'error',
|
|
107
|
-
'react/no-unused-prop-types': hasPropTypes ? 'error' : 'off',
|
|
108
|
-
'react/no-unused-state': 'error',
|
|
109
|
-
'react/no-will-update-set-state': 'error',
|
|
110
|
-
'react/prefer-es6-class': 'off',
|
|
111
|
-
'react/prefer-exact-props': 'off',
|
|
112
|
-
'react/prefer-read-only-props': 'off',
|
|
113
|
-
'react/prefer-stateless-function': 'off',
|
|
114
|
-
'react/prop-types': hasPropTypes ? 'error' : 'off',
|
|
115
|
-
'react/react-in-jsx-scope': 'error',
|
|
116
|
-
'react/require-default-props': 'off', // sometimes the default value is undefined so that's fine...
|
|
117
|
-
'react/require-optimization': 'off',
|
|
118
|
-
'react/require-render-return': 'error',
|
|
119
|
-
'react/self-closing-comp': 'error',
|
|
120
|
-
'react/sort-comp': 'off',
|
|
121
|
-
'react/sort-prop-types': 'off',
|
|
122
|
-
'react/state-in-constructor': 'off',
|
|
123
|
-
'react/static-property-placement': 'off',
|
|
124
|
-
'react/style-prop-object': 'error',
|
|
125
|
-
'react/void-dom-elements-no-children': 'error',
|
|
126
|
-
},
|
|
127
|
-
overrides: [
|
|
128
|
-
{
|
|
129
|
-
files: ['**/*.ts?(x)'],
|
|
130
|
-
rules: {
|
|
131
|
-
'react/jsx-filename-extension': [
|
|
132
|
-
'error',
|
|
133
|
-
{ extensions: ['.ts', '.tsx'] },
|
|
134
|
-
],
|
|
135
|
-
'react/prop-types': 'off',
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
}
|