@wistia/eslint-config 0.16.0 → 0.17.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wistia/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Wistia's ESLint configurations",
|
|
5
5
|
"main": "react.js",
|
|
6
6
|
"exports": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"./node": "./configs/eslint/node.js",
|
|
12
12
|
"./prettier": "./configs/eslint/prettier.js",
|
|
13
13
|
"./react": "./configs/eslint/react.js",
|
|
14
|
+
"./storybook": "./configs/eslint/storybook.js",
|
|
14
15
|
"./strict": "./configs/eslint/strict.js",
|
|
15
16
|
"./styled-components": "./configs/eslint/styled-components.js",
|
|
16
17
|
"./stylelint": "./configs/stylelint/default.js",
|
|
@@ -53,6 +54,7 @@
|
|
|
53
54
|
"eslint-plugin-react": "^7.31.10",
|
|
54
55
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
55
56
|
"eslint-plugin-sonarjs": "^0.16.0",
|
|
57
|
+
"eslint-plugin-storybook": "^0.6.7",
|
|
56
58
|
"eslint-plugin-styled-components-a11y": "^1.0.0",
|
|
57
59
|
"eslint-plugin-testing-library": "^5.9.1",
|
|
58
60
|
"postcss": "^8.4.18",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// only add storybook rules
|
|
2
|
+
// see: https://github.com/storybookjs/eslint-plugin-storybook#supported-rules-and-configurations
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
plugins: ['eslint-plugin-storybook'],
|
|
6
|
+
|
|
7
|
+
rules: {
|
|
8
|
+
// storybook 6 requires default exports in stories
|
|
9
|
+
'import/no-anonymous-default-export': 'off',
|
|
10
|
+
'import/no-default-export': 'off',
|
|
11
|
+
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
|
|
12
|
+
'import/prefer-default-export': 'error',
|
|
13
|
+
|
|
14
|
+
// Interactions should be awaited
|
|
15
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/await-interactions.md
|
|
16
|
+
'storybook/await-interactions': 'error',
|
|
17
|
+
|
|
18
|
+
// Pass a context when invoking play function of another story
|
|
19
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/context-in-play-function.md
|
|
20
|
+
'storybook/context-in-play-function': 'error',
|
|
21
|
+
|
|
22
|
+
// The component property should be set
|
|
23
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/csf-component.md
|
|
24
|
+
'storybook/csf-component': 'error',
|
|
25
|
+
|
|
26
|
+
// Story files should have a default export
|
|
27
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/default-exports.md
|
|
28
|
+
'storybook/default-exports': 'error',
|
|
29
|
+
|
|
30
|
+
// Deprecated hierarchy separator in title property
|
|
31
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/hierarchy-separator.md
|
|
32
|
+
'storybook/hierarchy-separator': 'error',
|
|
33
|
+
|
|
34
|
+
// A story should not have a redundant name property
|
|
35
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/no-redundant-story-name.md
|
|
36
|
+
'storybook/no-redundant-story-name': 'error',
|
|
37
|
+
|
|
38
|
+
// storiesOf is deprecated and should not be used
|
|
39
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/no-stories-of.md
|
|
40
|
+
'storybook/no-stories-of': 'error',
|
|
41
|
+
|
|
42
|
+
// Do not define a title in meta
|
|
43
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/no-title-property-in-meta.md
|
|
44
|
+
'storybook/no-title-property-in-meta': 'error',
|
|
45
|
+
|
|
46
|
+
// This rule identifies storybook addons that are invalid because they are either not installed or contain a typo in their name
|
|
47
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/no-uninstalled-addons.md
|
|
48
|
+
'storybook/no-uninstalled-addons': 'error',
|
|
49
|
+
|
|
50
|
+
// Stories should use PascalCase
|
|
51
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/prefer-pascal-case.md
|
|
52
|
+
'storybook/prefer-pascal-case': 'error',
|
|
53
|
+
|
|
54
|
+
// A story file must contain at least one story export
|
|
55
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/story-exports.md
|
|
56
|
+
'storybook/story-exports': 'error',
|
|
57
|
+
|
|
58
|
+
// Use expect from @storybook/jest
|
|
59
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/use-storybook-expect.md
|
|
60
|
+
'storybook/use-storybook-expect': 'error',
|
|
61
|
+
|
|
62
|
+
// Do not use testing-library directly on stories
|
|
63
|
+
// https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/storybook/use-storybook-testing-library.md
|
|
64
|
+
'storybook/use-storybook-testing-library': 'error',
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -12,12 +12,18 @@ module.exports = {
|
|
|
12
12
|
|
|
13
13
|
rules: {
|
|
14
14
|
...adjustedImportRules,
|
|
15
|
+
|
|
15
16
|
// turn on errors for missing imports
|
|
16
17
|
'import/no-unresolved': 'error',
|
|
18
|
+
|
|
19
|
+
//
|
|
20
|
+
'import/no-unused-modules': 'off',
|
|
17
21
|
},
|
|
18
22
|
|
|
19
23
|
settings: {
|
|
20
24
|
'import/parsers': {
|
|
25
|
+
// omit `.d.ts` because 1) TypeScript compilation already confirms that types are resolved, and
|
|
26
|
+
// 2) it would mask an unresolved `.ts`/`.tsx`/`.js`/`.jsx` implementation.
|
|
21
27
|
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
|
22
28
|
},
|
|
23
29
|
|
|
@@ -5,6 +5,16 @@ module.exports = {
|
|
|
5
5
|
plugins: ['@typescript-eslint'],
|
|
6
6
|
|
|
7
7
|
rules: {
|
|
8
|
+
// recommended to be disabled for TypeScript projects
|
|
9
|
+
// https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/TROUBLESHOOTING.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
|
10
|
+
'no-undef': 'off',
|
|
11
|
+
|
|
12
|
+
// prefer @typescript-eslint/no-unused-vars
|
|
13
|
+
'no-unused-vars': 'off',
|
|
14
|
+
|
|
15
|
+
// prefer @typescript-eslint/no-use-before-define
|
|
16
|
+
'no-use-before-define': 'off',
|
|
17
|
+
|
|
8
18
|
// Require that member overloads be consecutive
|
|
9
19
|
// https://typescript-eslint.io/rules/adjacent-overload-signatures
|
|
10
20
|
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
@@ -47,7 +57,7 @@ module.exports = {
|
|
|
47
57
|
|
|
48
58
|
// Enforce type definitions to consistently use either <code>interface</code> or <code>type</code>
|
|
49
59
|
// https://typescript-eslint.io/rules/consistent-type-definitions
|
|
50
|
-
'@typescript-eslint/consistent-type-definitions': '
|
|
60
|
+
'@typescript-eslint/consistent-type-definitions': 'off',
|
|
51
61
|
|
|
52
62
|
// Enforce consistent usage of type exports
|
|
53
63
|
// https://typescript-eslint.io/rules/consistent-type-exports
|
|
@@ -55,11 +65,16 @@ module.exports = {
|
|
|
55
65
|
|
|
56
66
|
// Enforce consistent usage of type imports
|
|
57
67
|
// https://typescript-eslint.io/rules/consistent-type-imports
|
|
58
|
-
'@typescript-eslint/consistent-type-imports':
|
|
68
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
69
|
+
'error',
|
|
70
|
+
{
|
|
71
|
+
prefer: 'no-type-imports',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
59
74
|
|
|
60
75
|
// Require explicit return types on functions and class methods
|
|
61
76
|
// https://typescript-eslint.io/rules/explicit-function-return-type
|
|
62
|
-
'@typescript-eslint/explicit-function-return-type': '
|
|
77
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
63
78
|
|
|
64
79
|
// Require explicit accessibility modifiers on class properties and methods
|
|
65
80
|
// https://typescript-eslint.io/rules/explicit-member-accessibility
|
|
@@ -83,7 +98,7 @@ module.exports = {
|
|
|
83
98
|
|
|
84
99
|
// Enforce naming conventions for everything across a codebase
|
|
85
100
|
// https://typescript-eslint.io/rules/naming-convention
|
|
86
|
-
'@typescript-eslint/naming-convention': '
|
|
101
|
+
'@typescript-eslint/naming-convention': 'off',
|
|
87
102
|
|
|
88
103
|
// Require <code>.toString()</code> to only be called on objects which provide useful information when stringified
|
|
89
104
|
// https://typescript-eslint.io/rules/no-base-to-string
|
|
@@ -187,7 +202,7 @@ module.exports = {
|
|
|
187
202
|
|
|
188
203
|
// Disallow type aliases
|
|
189
204
|
// https://typescript-eslint.io/rules/no-type-alias
|
|
190
|
-
'@typescript-eslint/no-type-alias': '
|
|
205
|
+
'@typescript-eslint/no-type-alias': 'off',
|
|
191
206
|
|
|
192
207
|
// Disallow unnecessary equality comparisons against boolean literals
|
|
193
208
|
// https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare
|
|
@@ -291,7 +306,8 @@ module.exports = {
|
|
|
291
306
|
|
|
292
307
|
// Require function parameters to be typed as <code>readonly</code> to prevent accidental mutation of inputs
|
|
293
308
|
// https://typescript-eslint.io/rules/prefer-readonly-parameter-types
|
|
294
|
-
|
|
309
|
+
// disabled due to development friction and lackluster linting hints to resolve violations
|
|
310
|
+
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
|
|
295
311
|
|
|
296
312
|
// Enforce using type parameter when calling <code>Array#reduce</code> instead of casting
|
|
297
313
|
// https://typescript-eslint.io/rules/prefer-reduce-type-parameter
|
|
@@ -448,7 +464,18 @@ module.exports = {
|
|
|
448
464
|
|
|
449
465
|
// Disallow magic numbers
|
|
450
466
|
// https://typescript-eslint.io/rules/no-magic-numbers
|
|
451
|
-
'@typescript-eslint/no-magic-numbers':
|
|
467
|
+
'@typescript-eslint/no-magic-numbers': [
|
|
468
|
+
'error',
|
|
469
|
+
{
|
|
470
|
+
ignore: [0, 1, 2, 3, 4, 5, 1000],
|
|
471
|
+
ignoreArrayIndexes: true,
|
|
472
|
+
ignoreDefaultValues: true,
|
|
473
|
+
ignoreTypeIndexes: true,
|
|
474
|
+
ignoreReadonlyClassProperties: true,
|
|
475
|
+
ignoreEnums: true,
|
|
476
|
+
ignoreNumericLiteralTypes: true,
|
|
477
|
+
},
|
|
478
|
+
],
|
|
452
479
|
|
|
453
480
|
// Disallow variable redeclaration
|
|
454
481
|
// https://typescript-eslint.io/rules/no-redeclare
|