@perfective/eslint-config 0.29.2 → 0.31.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/LICENSE +1 -1
- package/README.adoc +198 -67
- package/README.md +62 -45
- package/config/array-func/array-func-config.d.ts +2 -0
- package/config/array-func/array-func-config.js +16 -0
- package/config/cypress/cypress-config.d.ts +10 -0
- package/config/cypress/cypress-config.js +38 -0
- package/config/cypress/index.d.ts +1 -0
- package/config/cypress/index.js +1 -0
- package/config/eslint/eslint-config.d.ts +2 -0
- package/config/eslint/eslint-config.js +8 -0
- package/config/eslint/layout-formatting-rules.d.ts +2 -0
- package/config/eslint/layout-formatting-rules.js +64 -0
- package/config/eslint/possible-problems-rules.d.ts +2 -0
- package/config/eslint/possible-problems-rules.js +96 -0
- package/config/eslint/suggestions-rules.d.ts +2 -0
- package/config/eslint/suggestions-rules.js +181 -0
- package/config/eslint-comments/best-practices-rules.d.ts +2 -0
- package/config/eslint-comments/best-practices-rules.js +8 -0
- package/config/eslint-comments/eslint-comments-config.d.ts +2 -0
- package/config/eslint-comments/eslint-comments-config.js +11 -0
- package/config/eslint-comments/stylistic-issues-rules.d.ts +2 -0
- package/config/eslint-comments/stylistic-issues-rules.js +9 -0
- package/config/import/helpful-warnings-rules.d.ts +2 -0
- package/config/import/helpful-warnings-rules.js +11 -0
- package/config/import/import-config.d.ts +4 -0
- package/config/import/import-config.js +46 -0
- package/config/import/index.d.ts +1 -0
- package/config/import/index.js +1 -0
- package/config/import/module-systems-rules.d.ts +2 -0
- package/config/import/module-systems-rules.js +10 -0
- package/config/import/rules/no-extraneous-dependencies.d.ts +15 -0
- package/config/import/rules/no-extraneous-dependencies.js +8 -0
- package/config/import/static-analysis-rules.d.ts +2 -0
- package/config/import/static-analysis-rules.js +26 -0
- package/config/import/style-guide-rules.d.ts +2 -0
- package/config/import/style-guide-rules.js +33 -0
- package/config/jest/index.d.ts +1 -0
- package/config/jest/index.js +1 -0
- package/config/jest/jest-config.d.ts +8 -0
- package/config/jest/jest-config.js +128 -0
- package/config/jest/typescript-eslint-jest-rules.d.ts +2 -0
- package/config/jest/typescript-eslint-jest-rules.js +5 -0
- package/config/jest-dom/index.d.ts +1 -0
- package/config/jest-dom/index.js +1 -0
- package/config/jest-dom/jest-dom-config.d.ts +8 -0
- package/config/jest-dom/jest-dom-config.js +23 -0
- package/config/jsdoc/jsdoc-config.d.ts +3 -0
- package/config/jsdoc/jsdoc-config.js +179 -0
- package/config/node/node-config.d.ts +2 -0
- package/config/node/node-config.js +66 -0
- package/config/perfective-eslint-config.d.ts +6 -0
- package/config/perfective-eslint-config.js +45 -0
- package/config/prefer-arrow/prefer-arrow-config.d.ts +2 -0
- package/config/prefer-arrow/prefer-arrow-config.js +16 -0
- package/config/promise/promise-config.d.ts +2 -0
- package/config/promise/promise-config.js +37 -0
- package/config/rxjs/index.d.ts +1 -0
- package/config/rxjs/index.js +1 -0
- package/config/rxjs/rxjs-config.d.ts +8 -0
- package/config/rxjs/rxjs-config.js +67 -0
- package/config/security/security-config.d.ts +2 -0
- package/config/security/security-config.js +24 -0
- package/config/simple-import-sort/index.d.ts +1 -0
- package/config/simple-import-sort/index.js +1 -0
- package/config/simple-import-sort/rules/imports.d.ts +28 -0
- package/config/simple-import-sort/rules/imports.js +32 -0
- package/config/simple-import-sort/simple-import-sort-config.d.ts +2 -0
- package/config/simple-import-sort/simple-import-sort-config.js +13 -0
- package/config/stylistic/js/stylistic-js-config.d.ts +2 -0
- package/config/stylistic/js/stylistic-js-config.js +200 -0
- package/config/stylistic/jsx/stylistic-jsx-config.d.ts +2 -0
- package/config/stylistic/jsx/stylistic-jsx-config.js +87 -0
- package/config/stylistic/plus/stylistic-plus-config.d.ts +2 -0
- package/config/stylistic/plus/stylistic-plus-config.js +16 -0
- package/config/stylistic/ts/stylistic-ts-config.d.ts +2 -0
- package/config/stylistic/ts/stylistic-ts-config.js +141 -0
- package/config/testing-library/index.d.ts +1 -0
- package/config/testing-library/index.js +1 -0
- package/config/testing-library/testing-library-config.d.ts +8 -0
- package/config/testing-library/testing-library-config.js +45 -0
- package/config/typescript-eslint/extension-rules.d.ts +2 -0
- package/config/typescript-eslint/extension-rules.js +113 -0
- package/config/typescript-eslint/index.d.ts +1 -0
- package/config/typescript-eslint/index.js +1 -0
- package/{rules → config}/typescript-eslint/rules/typescript-eslint-naming-convention.d.ts +39 -0
- package/config/typescript-eslint/rules/typescript-eslint-naming-convention.js +26 -0
- package/config/typescript-eslint/supported-rules.d.ts +2 -0
- package/config/typescript-eslint/supported-rules.js +260 -0
- package/config/typescript-eslint/typescript-eslint-config.d.ts +2 -0
- package/config/typescript-eslint/typescript-eslint-config.js +15 -0
- package/config/unicorn/index.d.ts +1 -0
- package/config/unicorn/index.js +1 -0
- package/{rules → config}/unicorn/rules/prevent-abbreviations.d.ts +20 -0
- package/config/unicorn/rules/prevent-abbreviations.js +30 -0
- package/config/unicorn/unicorn-config.d.ts +2 -0
- package/config/unicorn/unicorn-config.js +185 -0
- package/index.d.ts +5 -1732
- package/index.js +5 -146
- package/linter/glob.d.ts +59 -0
- package/linter/glob.js +8 -0
- package/linter/language-options.d.ts +25 -0
- package/linter/language-options.js +45 -0
- package/linter/linter-config.d.ts +13 -0
- package/linter/linter-config.js +6 -0
- package/linter/node.d.ts +10 -0
- package/linter/node.js +7 -0
- package/linter/plugin.d.ts +15 -0
- package/linter/plugin.js +26 -0
- package/package.json +45 -45
- package/config/node.d.ts +0 -1
- package/config/node.js +0 -11
- package/config/plugin.d.ts +0 -2
- package/config/plugin.js +0 -30
- package/config.d.ts +0 -1
- package/config.js +0 -6
- package/cypress.d.ts +0 -1
- package/cypress.js +0 -56
- package/jest-dom.d.ts +0 -1
- package/jest-dom.js +0 -11
- package/jest.d.ts +0 -1
- package/jest.js +0 -24
- package/rules/array-func/index.d.ts +0 -14
- package/rules/array-func/index.js +0 -50
- package/rules/cypress/index.d.ts +0 -21
- package/rules/cypress/index.js +0 -57
- package/rules/eslint/index.d.ts +0 -339
- package/rules/eslint/index.js +0 -9
- package/rules/eslint/layout-formatting.d.ts +0 -64
- package/rules/eslint/layout-formatting.js +0 -67
- package/rules/eslint/possible-problems.d.ts +0 -96
- package/rules/eslint/possible-problems.js +0 -99
- package/rules/eslint/suggestions.d.ts +0 -181
- package/rules/eslint/suggestions.js +0 -182
- package/rules/eslint-comments/best-practices.d.ts +0 -8
- package/rules/eslint-comments/best-practices.js +0 -11
- package/rules/eslint-comments/index.d.ts +0 -21
- package/rules/eslint-comments/index.js +0 -45
- package/rules/eslint-comments/stylistic-issues.d.ts +0 -9
- package/rules/eslint-comments/stylistic-issues.js +0 -18
- package/rules/import/helpful-warnings.d.ts +0 -10
- package/rules/import/helpful-warnings.js +0 -14
- package/rules/import/index.d.ts +0 -78
- package/rules/import/index.js +0 -14
- package/rules/import/module-systems.d.ts +0 -10
- package/rules/import/module-systems.js +0 -13
- package/rules/import/rules/no-extraneous-dependencies.d.ts +0 -11
- package/rules/import/rules/no-extraneous-dependencies.js +0 -24
- package/rules/import/static-analysis.d.ts +0 -26
- package/rules/import/static-analysis.js +0 -29
- package/rules/import/style-guide.d.ts +0 -33
- package/rules/import/style-guide.js +0 -36
- package/rules/jest/index.d.ts +0 -124
- package/rules/jest/index.js +0 -72
- package/rules/jest/typescript-eslint.d.ts +0 -5
- package/rules/jest/typescript-eslint.js +0 -8
- package/rules/jest-dom/index.d.ts +0 -32
- package/rules/jest-dom/index.js +0 -55
- package/rules/jsdoc/index.d.ts +0 -134
- package/rules/jsdoc/index.js +0 -347
- package/rules/n/index.d.ts +0 -66
- package/rules/n/index.js +0 -98
- package/rules/prefer-arrow/index.d.ts +0 -14
- package/rules/prefer-arrow/index.js +0 -50
- package/rules/promise/index.d.ts +0 -35
- package/rules/promise/index.js +0 -73
- package/rules/rxjs/index.d.ts +0 -60
- package/rules/rxjs/index.js +0 -96
- package/rules/security/index.d.ts +0 -22
- package/rules/security/index.js +0 -58
- package/rules/simple-import-sort/index.d.ts +0 -10
- package/rules/simple-import-sort/index.js +0 -48
- package/rules/simple-import-sort/rules/imports.d.ts +0 -8
- package/rules/simple-import-sort/rules/imports.js +0 -46
- package/rules/stylistic/js/index.d.ts +0 -197
- package/rules/stylistic/js/index.js +0 -236
- package/rules/stylistic/jsx/index.d.ts +0 -81
- package/rules/stylistic/jsx/index.js +0 -117
- package/rules/stylistic/plus/index.d.ts +0 -14
- package/rules/stylistic/plus/index.js +0 -50
- package/rules/stylistic/ts/index.d.ts +0 -135
- package/rules/stylistic/ts/index.js +0 -169
- package/rules/testing-library/index.d.ts +0 -62
- package/rules/testing-library/index.js +0 -77
- package/rules/typescript-eslint/extension-rules.d.ts +0 -113
- package/rules/typescript-eslint/extension-rules.js +0 -116
- package/rules/typescript-eslint/index.d.ts +0 -369
- package/rules/typescript-eslint/index.js +0 -45
- package/rules/typescript-eslint/rules/typescript-eslint-naming-convention.js +0 -32
- package/rules/typescript-eslint/supported-rules.d.ts +0 -253
- package/rules/typescript-eslint/supported-rules.js +0 -319
- package/rules/unicorn/index.d.ts +0 -178
- package/rules/unicorn/index.js +0 -209
- package/rules/unicorn/rules/prevent-abbreviations.js +0 -8
- package/rules.d.ts +0 -4
- package/rules.js +0 -14
- package/rxjs.d.ts +0 -1
- package/rxjs.js +0 -58
- package/testing-library.d.ts +0 -1
- package/testing-library.js +0 -11
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2020-
|
|
3
|
+
Copyright (c) 2020-2025 Andrey Mikheychik (https://github.com/amikheychik)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.adoc
CHANGED
|
@@ -12,7 +12,7 @@ and https://eslint.style[ESLint Stylistic] plugin rules,
|
|
|
12
12
|
|
|
13
13
|
* `link:https://github.com/freaktechnik/eslint-plugin-array-func[eslint-plugin-array-func]`;
|
|
14
14
|
* `link:https://github.com/cypress-io/eslint-plugin-cypress[eslint-plugin-cypress]` _(optional)_;
|
|
15
|
-
* `link:https://
|
|
15
|
+
* `link:https://eslint-community.github.io/eslint-plugin-eslint-comments/[@eslint-community/eslint-plugin-eslint-comments]`;
|
|
16
16
|
* `link:https://github.com/import-js/eslint-plugin-import[eslint-plugin-import]`;
|
|
17
17
|
* `link:https://github.com/jest-community/eslint-plugin-jest[eslint-plugin-jest]` _(optional)_;
|
|
18
18
|
* `link:https://github.com/testing-library/eslint-plugin-jest-dom[eslint-plugin-jest-dom]` _(optional)_;
|
|
@@ -20,7 +20,7 @@ and https://eslint.style[ESLint Stylistic] plugin rules,
|
|
|
20
20
|
* `link:https://github.com/eslint-community/eslint-plugin-n[eslint-plugin-n]`;
|
|
21
21
|
* `link:https://github.com/TristonJ/eslint-plugin-prefer-arrow[eslint-plugin-prefer-arrow]`;
|
|
22
22
|
* `link:https://github.com/eslint-community/eslint-plugin-promise[eslint-plugin-promise]`;
|
|
23
|
-
* `link:https://github.com/
|
|
23
|
+
* `link:https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x[eslint-plugin-rxjs-x]` _(optional)_;
|
|
24
24
|
* `link:https://github.com/eslint-community/eslint-plugin-security[eslint-plugin-security]`;
|
|
25
25
|
* `link:https://github.com/lydell/eslint-plugin-simple-import-sort[eslint-plugin-simple-import-sort]`;
|
|
26
26
|
* `link:https://github.com/testing-library/eslint-plugin-testing-library[eslint-plugin-testing-library]` _(optional)_;
|
|
@@ -34,80 +34,100 @@ from issues that will be fixed automatically.
|
|
|
34
34
|
|
|
35
35
|
== Setup
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
IMPORTANT: `@perfective/eslint-config` only support ES module syntax.
|
|
38
|
+
If your project uses CommonJS by default
|
|
39
|
+
you need to use `eslint.config.mjs` file instead of `eslint.config.js` to run it in ESM mode.
|
|
40
|
+
|
|
41
|
+
. Install `@perfective/eslint-config` as a dev dependency:
|
|
38
42
|
+
|
|
39
43
|
[source,bash]
|
|
40
44
|
----
|
|
41
|
-
npm install --save-dev
|
|
42
|
-
@perfective/eslint-config \
|
|
43
|
-
@stylistic/eslint-plugin \
|
|
44
|
-
@stylistic/eslint-plugin-js \
|
|
45
|
-
@stylistic/eslint-plugin-jsx \
|
|
46
|
-
@stylistic/eslint-plugin-ts \
|
|
47
|
-
@stylistic/eslint-plugin-plus \
|
|
48
|
-
eslint \
|
|
49
|
-
eslint-import-resolver-typescript \
|
|
50
|
-
eslint-plugin-array-func \
|
|
51
|
-
eslint-plugin-eslint-comments \
|
|
52
|
-
eslint-plugin-import \
|
|
53
|
-
eslint-plugin-jsdoc \
|
|
54
|
-
eslint-plugin-n \
|
|
55
|
-
eslint-plugin-prefer-arrow \
|
|
56
|
-
eslint-plugin-promise \
|
|
57
|
-
eslint-plugin-security \
|
|
58
|
-
eslint-plugin-simple-import-sort \
|
|
59
|
-
eslint-plugin-unicorn \
|
|
60
|
-
typescript-eslint
|
|
45
|
+
npm install --save-dev @perfective/eslint-config
|
|
61
46
|
----
|
|
62
47
|
+
|
|
63
|
-
|
|
48
|
+
Required peer dependencies are installed automatically.
|
|
49
|
+
+
|
|
50
|
+
. Import `perfectiveEslintConfig` to `eslint.config.js`.
|
|
64
51
|
+
|
|
65
52
|
[source,javascript]
|
|
66
53
|
----
|
|
67
|
-
|
|
54
|
+
import { perfectiveEslintConfig } from '@perfective/eslint-config';
|
|
55
|
+
|
|
56
|
+
const eslintConfig = perfectiveEslintConfig();
|
|
68
57
|
|
|
69
|
-
|
|
58
|
+
export default eslintConfig;
|
|
70
59
|
----
|
|
71
60
|
+
|
|
72
|
-
.
|
|
73
|
-
`node_modules` and dot-files are ignored by the `eslint`.
|
|
74
|
-
If more directories or file types need to be ignored, see the
|
|
75
|
-
`link:https://eslint.org/docs/user-guide/configuring/ignoring-code#the-eslintignore-file[.eslintignore]` file docs.
|
|
76
|
-
+
|
|
77
|
-
. Install optional peer dependencies that add linting rules for the tools you use.
|
|
61
|
+
. _Optional_ Install optional peer dependencies to add tool-specific linting rules.
|
|
78
62
|
+
|
|
79
63
|
[source,bash]
|
|
80
64
|
----
|
|
81
65
|
npm install --save-dev \
|
|
82
|
-
@smarttools/eslint-plugin-rxjs \
|
|
83
66
|
eslint-plugin-cypress \
|
|
84
67
|
eslint-plugin-jest \
|
|
85
68
|
eslint-plugin-jest-dom \
|
|
69
|
+
eslint-plugin-rxjs-x \
|
|
86
70
|
eslint-plugin-testing-library
|
|
87
71
|
----
|
|
88
72
|
+
|
|
89
|
-
|
|
73
|
+
Import configurations to `eslint.config.js`.
|
|
90
74
|
+
|
|
91
75
|
[source,javascript]
|
|
92
76
|
----
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
77
|
+
import { perfectiveEslintConfig } from '@perfective/eslint-config';
|
|
78
|
+
|
|
79
|
+
// Optional dependencies.
|
|
80
|
+
import { cypressConfig } from '@perfective/eslint-config/cypress';
|
|
81
|
+
import { jestConfig } from '@perfective/eslint-config/jest';
|
|
82
|
+
import { jestDomConfig } from '@perfective/eslint-config/jest-dom';
|
|
83
|
+
import { rxjsConfig } from '@perfective/eslint-config/rxjs';
|
|
84
|
+
import { testingLibraryConfig } from '@perfective/eslint-config/testing-library';
|
|
85
|
+
|
|
86
|
+
const eslintConfig = perfectiveEslintConfig([
|
|
87
|
+
cypressConfig,
|
|
88
|
+
jestConfig,
|
|
89
|
+
jestDomConfig,
|
|
90
|
+
rxjsConfig,
|
|
91
|
+
testingLibraryConfig,
|
|
92
|
+
]);
|
|
93
|
+
|
|
94
|
+
export default eslintConfig;
|
|
95
|
+
----
|
|
96
|
+
+
|
|
97
|
+
. _Optional_ Customize configuration rules in `eslint.config.js`
|
|
98
|
+
+
|
|
99
|
+
[source,javascript]
|
|
108
100
|
----
|
|
101
|
+
import { perfectiveEslintConfig, typescriptFiles } from '@perfective/eslint-config'; // <.>
|
|
102
|
+
|
|
103
|
+
const eslintConfig = perfectiveEslintConfig([
|
|
104
|
+
// ...Optional configurations...
|
|
105
|
+
{
|
|
106
|
+
// These rules are overridden to all files
|
|
107
|
+
rules: {
|
|
108
|
+
'@stylistic/js/indent': ['warn', 2],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
// These rules are overridden to TypeScript files only
|
|
113
|
+
files: typescriptFiles,
|
|
114
|
+
rules: {
|
|
115
|
+
'@stylistic/ts/indent': ['warn', 2],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
export default eslintConfig;
|
|
121
|
+
----
|
|
122
|
+
<.> See the list of available globs below.
|
|
123
|
+
|
|
124
|
+
NOTE: `*.d.ts` files and `dist` directories are ignored by the configuration.
|
|
125
|
+
`node_modules` and dot-files are ignored by the `eslint`.
|
|
126
|
+
If more directories or file types need to be ignored, see the
|
|
127
|
+
`link:https://eslint.org/docs/latest/use/configure/ignore#the-eslintignore-file[.eslintignore]` file docs.
|
|
128
|
+
|
|
109
129
|
|
|
110
|
-
== Rules
|
|
130
|
+
== Rules configuration functions
|
|
111
131
|
|
|
112
132
|
Some rules have complex configuration objects or arrays
|
|
113
133
|
that are not merged but are completely overridden by ESLint.
|
|
@@ -115,39 +135,150 @@ Therefore, it requires copying and pasting a rule config instead of just extendi
|
|
|
115
135
|
Maintaining rules updates is challenging
|
|
116
136
|
and is simplified by the custom config functions.
|
|
117
137
|
|
|
118
|
-
These functions and related types are exported
|
|
138
|
+
These functions and related types are exported from the link:#_packages[subpackages]
|
|
119
139
|
and match the rule name in `camelCase`.
|
|
120
140
|
If you need an extended configuration,
|
|
121
141
|
you can use these functions in the `eslint.config.js` file:
|
|
122
142
|
|
|
123
143
|
[source,javascript]
|
|
124
144
|
----
|
|
125
|
-
|
|
126
|
-
|
|
145
|
+
import perfectiveEslintConfig from '@perfective/eslint-config';
|
|
146
|
+
import { simpleImportSortImports } from '@perfective/eslint-config/simple-import-sort'; // <.>
|
|
127
147
|
|
|
128
|
-
|
|
129
|
-
...
|
|
148
|
+
const eslintConfig = perfectiveEslintConfig([
|
|
149
|
+
// ...Optional configurations...
|
|
130
150
|
{
|
|
131
|
-
files: ['**/*.[jt]s?(x)'],
|
|
132
151
|
rules: {
|
|
133
|
-
'simple-import-sort/imports': ['warn',
|
|
152
|
+
'simple-import-sort/imports': ['warn', simpleImportSortImports([
|
|
134
153
|
'@perfective',
|
|
135
154
|
])],
|
|
136
155
|
},
|
|
137
156
|
},
|
|
138
|
-
];
|
|
157
|
+
]);
|
|
158
|
+
|
|
159
|
+
export default eslintConfig;
|
|
139
160
|
----
|
|
140
161
|
<1> Framework-specific packages, based on `@perfective/eslint-config`, re-export all the rules.
|
|
141
162
|
So rules should be required from those packages for correct `node_modules` resolution.
|
|
142
163
|
|
|
143
164
|
|
|
144
|
-
|
|
165
|
+
== Packages [#packages]
|
|
166
|
+
|
|
167
|
+
The following is the list of available packages and their exports.
|
|
168
|
+
|
|
169
|
+
=== `@perfective/eslint-config`
|
|
170
|
+
|
|
171
|
+
* `perfectiveEslintConfig`
|
|
172
|
+
— a function that creates an array of flat configs.
|
|
173
|
+
+
|
|
174
|
+
* `type Glob = string`
|
|
175
|
+
a nominal type for glob patterns.
|
|
176
|
+
** `javascriptFiles: Glob[]`
|
|
177
|
+
— a list of glob patterns for JS and JSX files.
|
|
178
|
+
** `jsxFiles: Glob`
|
|
179
|
+
— a glob pattern for JSX files.
|
|
180
|
+
** `typescriptFiles: Glob[]`
|
|
181
|
+
— a list of glob patterns for TypeScript source files.
|
|
182
|
+
** `tsxFiles: Glob`
|
|
183
|
+
— a glob pattern for TSX files.
|
|
184
|
+
** `typescriptDeclarationFiles: Glob`
|
|
185
|
+
— a glob pattern for TypeScript declaration files.
|
|
186
|
+
** `configurationFiles: Glob`
|
|
187
|
+
— a glob pattern for JavaScript tools configuration files.
|
|
188
|
+
** `jestFiles: Glob[]`
|
|
189
|
+
— the link:https://jestjs.io/docs/configuration#testmatch-arraystring[default] glob patterns
|
|
190
|
+
Jest uses to find test files.
|
|
191
|
+
** `cypressFiles: Glob`
|
|
192
|
+
— the link:https://docs.cypress.io/app/references/configuration#e2e[default] glob pattern
|
|
193
|
+
Cypress uses to load test files.
|
|
194
|
+
+
|
|
195
|
+
* ESLint language options:
|
|
196
|
+
** `languageOptions(): Linter.LanguageOptions`
|
|
197
|
+
— creates ESLint `languageOptions` object for all files.
|
|
198
|
+
** `javascriptLanguageOptions(): Linter.LanguageOptions`
|
|
199
|
+
— creates ESLint `languageOptions` object for JavaScript files.
|
|
200
|
+
** `typescriptLanguageOptions(): Linter.LanguageOptions`
|
|
201
|
+
— creates ESLint `languageOptions` object for TypeScript files.
|
|
202
|
+
+
|
|
203
|
+
* `type LinterConfig = Linter.Config | (() => Linter.Config)`
|
|
204
|
+
— an ESLint flat config or a function that returns one.
|
|
205
|
+
** `linterConfig(config: LinterConfig): Linter.Config`
|
|
206
|
+
— a function to instantiate ESLint flat config.
|
|
207
|
+
+
|
|
208
|
+
* Optional plugins:
|
|
209
|
+
** `hasEslintPlugin`
|
|
210
|
+
— returns true if a given ESLint plugin exists.
|
|
211
|
+
** `optionalRule(rule: string, config: unknown): Record<string, unknown>`
|
|
212
|
+
— returns an object with rule as a key
|
|
213
|
+
and its config as a value,
|
|
214
|
+
if a given rule belongs to an installed ESLint plugin.
|
|
215
|
+
|
|
216
|
+
=== `@perfective/eslint-config/cypress`
|
|
217
|
+
|
|
218
|
+
* `cypressConfig(files: Glob[] = [cypressFiles]): Linter.Config`
|
|
219
|
+
— creates a flat config for `eslint-plugin-cypress`
|
|
220
|
+
for a given list of files globs.
|
|
221
|
+
Overrides some rules for `perfectiveEslintConfig` for compatibility with Cypress.
|
|
222
|
+
|
|
223
|
+
=== `@perfective/eslint-config/import`
|
|
224
|
+
|
|
225
|
+
* `interface ImportNoExtraneousDependencies`
|
|
226
|
+
— configuration options for the `import/no-extraneous-dependencies` rule.
|
|
227
|
+
** `importNoExtraneousDependencies(overrides: Partial<ImportNoExtraneousDependencies> = {}): ImportNoExtraneousDependencies`
|
|
228
|
+
— returns configuration options for the `import/no-extraneous-dependencies` rule.
|
|
229
|
+
|
|
230
|
+
=== `@perfective/eslint-config/jest`
|
|
231
|
+
|
|
232
|
+
* `jestConfig(files: Glob[] = jestFiles): Linter.Config`
|
|
233
|
+
— creates a flat config for `eslint-plugin-jest` for a given list of files globs.
|
|
234
|
+
|
|
235
|
+
=== `@perfective/eslint-config/jest-dom`
|
|
236
|
+
|
|
237
|
+
* `jestDomConfig(files: Glob[] = jestFiles): Linter.Config`
|
|
238
|
+
— creates a flat config for `eslint-plugin-jest-dom` for a given list of files globs.
|
|
239
|
+
|
|
240
|
+
=== `@perfective/eslint-config/rxjs`
|
|
241
|
+
|
|
242
|
+
* `rxjsConfig(files: Glob[] = typescriptFiles): Linter.Config`
|
|
243
|
+
— creates a flat config for `eslint-plugin-rxjs-x` for a given list of files globs.
|
|
244
|
+
|
|
245
|
+
=== `@perfective/eslint-config/simple-import-sort`
|
|
246
|
+
|
|
247
|
+
* `interface SimpleImportSortImports`
|
|
248
|
+
— configuration options for the `simple-import-sort/imports` rule.
|
|
249
|
+
** `simpleImportSortImports(internal: string[] = []): SimpleImportSortImports`
|
|
250
|
+
— creates configuration for the `simple-import-sort/imports` ESLint rule.
|
|
251
|
+
Allows to splice `internal` scope packages imports between the global and relative imports.
|
|
252
|
+
|
|
253
|
+
=== `@perfective/eslint-config/testing-library`
|
|
254
|
+
|
|
255
|
+
* `testingLibraryConfig(files: Glob[] = jestFiles): Linter.Config`
|
|
256
|
+
— creates a flat config for `eslint-plugin-testing-library` for a given list of files globs.
|
|
257
|
+
|
|
258
|
+
=== `@perfective/eslint-config/typescript-eslint`
|
|
259
|
+
|
|
260
|
+
* `interface TypescriptEslintNamingConvention`
|
|
261
|
+
— configuration options for the
|
|
262
|
+
`link:https://typescript-eslint.io/rules/naming-convention/[@typescript-eslint/naming-convention]` rule.
|
|
263
|
+
** `type TypescriptEslintNamingConventionSelector`
|
|
264
|
+
— values for the `@typescript-eslint/naming-convention` rule `selector` option.
|
|
265
|
+
*** `type TypescriptEslintNamingConventionIndividualSelector`
|
|
266
|
+
— values for individual selectors for the `@typescript-eslint/naming-convention` rule `selector` option.
|
|
267
|
+
*** `type TypescriptEslintNamingConventionGroupSelector`
|
|
268
|
+
— values for grouped of individual selectors for the `@typescript-eslint/naming-convention` rule `selector` option.
|
|
269
|
+
** `type TypescriptEslintNamingConventionFormat`
|
|
270
|
+
— values for the `@typescript-eslint/naming-convention` rule `format` option.
|
|
271
|
+
** `type TypescriptEslintNamingConventionUnderscore`
|
|
272
|
+
— values for the `@typescript-eslint/naming-convention` rule `leadingUnderscore` and `trailingUnderscore` options.
|
|
273
|
+
** `function typescriptEslintNamingConvention(extensions: TypescriptEslintNamingConvention[] = []): TypescriptEslintNamingConvention[]`
|
|
274
|
+
— creates configuration with the given extensions for the `@typescript-eslint/naming-convention` rule.
|
|
275
|
+
|
|
276
|
+
=== `@perfective/eslint-config/unicorn`
|
|
145
277
|
|
|
146
|
-
* `
|
|
147
|
-
—
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
—
|
|
151
|
-
|
|
152
|
-
—
|
|
153
|
-
and `options` for the `unicorn/prevent-abbreviation` rule.
|
|
278
|
+
* `interface UnicornPreventAbbreviations`
|
|
279
|
+
— configuration options for the
|
|
280
|
+
`link:https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prevent-abbreviations.md[unicorn/prevent-abbreviation]` rule.
|
|
281
|
+
** `type UnicornPreventAbbreviationReplacements`
|
|
282
|
+
— nominal type for the `replacements` option of the `unicorn/prevent-abbreviation` rule.
|
|
283
|
+
** `function unicornPreventAbbreviations( replacements: UnicornPreventAbbreviationReplacements = {}, options: Partial<Pick<UnicornPreventAbbreviations, 'checkProperties'>> = {}): UnicornPreventAbbreviations`
|
|
284
|
+
— creates configuration for the `unicorn/prevent-abbreviation` rule with the given replacements and options.
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ and [ESlint Stylistic](https://eslint.style) plugin rules,
|
|
|
12
12
|
|
|
13
13
|
- [`eslint-plugin-array-func`](https://github.com/freaktechnik/eslint-plugin-array-func);
|
|
14
14
|
- [`eslint-plugin-cypress`](https://github.com/cypress-io/eslint-plugin-cypress) _(optional)_;
|
|
15
|
-
- [`eslint-plugin-eslint-comments`](https://
|
|
15
|
+
- [`eslint-plugin-eslint-comments`](https://eslint-community.github.io/eslint-plugin-eslint-comments/);
|
|
16
16
|
- [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import);
|
|
17
17
|
- [`eslint-plugin-jest`](https://github.com/jest-community/eslint-plugin-jest) _(optional)_;
|
|
18
18
|
- [`eslint-plugin-jest-dom`](https://github.com/testing-library/eslint-plugin-jest-dom) _(optional)_;
|
|
@@ -20,7 +20,7 @@ and [ESlint Stylistic](https://eslint.style) plugin rules,
|
|
|
20
20
|
- [`eslint-plugin-n`](https://github.com/eslint-community/eslint-plugin-n);
|
|
21
21
|
- [`eslint-plugin-prefer-arrow`](https://github.com/TristonJ/eslint-plugin-prefer-arrow);
|
|
22
22
|
- [`eslint-plugin-promise`](https://github.com/eslint-community/eslint-plugin-promise);
|
|
23
|
-
- [`eslint-plugin-rxjs`](https://github.com/
|
|
23
|
+
- [`eslint-plugin-rxjs`](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x) _(optional)_;
|
|
24
24
|
- [`eslint-plugin-security`](https://github.com/eslint-community/eslint-plugin-security);
|
|
25
25
|
- [`eslint-plugin-simple-import-sort`](https://github.com/lydell/eslint-plugin-simple-import-sort);
|
|
26
26
|
- [`eslint-plugin-testing-library`](https://github.com/testing-library/eslint-plugin-testing-library) _(optional)_;
|
|
@@ -33,69 +33,86 @@ from issues that will be fixed automatically.
|
|
|
33
33
|
|
|
34
34
|
## Setup
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
`@perfective/eslint-config` only support ES module syntax.
|
|
37
|
+
If your project uses CommonJS by default
|
|
38
|
+
you need to use `eslint.config.mjs` file instead of `eslint.config.js` to run it in ESM mode.
|
|
39
|
+
|
|
40
|
+
1. Install `@perfective/eslint-config` as a dev dependency:
|
|
37
41
|
|
|
38
42
|
```bash
|
|
39
43
|
npm install --save-dev \
|
|
40
|
-
@perfective/eslint-config
|
|
41
|
-
@stylistic/eslint-plugin \
|
|
42
|
-
@stylistic/eslint-plugin-js \
|
|
43
|
-
@stylistic/eslint-plugin-jsx \
|
|
44
|
-
@stylistic/eslint-plugin-ts \
|
|
45
|
-
@stylistic/eslint-plugin-plus \
|
|
46
|
-
eslint \
|
|
47
|
-
eslint-import-resolver-typescript \
|
|
48
|
-
eslint-plugin-array-func \
|
|
49
|
-
eslint-plugin-eslint-comments \
|
|
50
|
-
eslint-plugin-import \
|
|
51
|
-
eslint-plugin-jsdoc \
|
|
52
|
-
eslint-plugin-n \
|
|
53
|
-
eslint-plugin-prefer-arrow \
|
|
54
|
-
eslint-plugin-promise \
|
|
55
|
-
eslint-plugin-security \
|
|
56
|
-
eslint-plugin-simple-import-sort \
|
|
57
|
-
eslint-plugin-unicorn \
|
|
58
|
-
typescript-eslint
|
|
44
|
+
@perfective/eslint-config
|
|
59
45
|
```
|
|
60
46
|
|
|
61
|
-
|
|
47
|
+
Required peer dependencies are installed automatically.
|
|
48
|
+
|
|
49
|
+
2. Import `perfectiveEslintConfig` to `eslint.config.js`.
|
|
62
50
|
|
|
63
51
|
```javascript
|
|
64
|
-
|
|
52
|
+
import { perfectiveEslintConfig } from '@perfective/eslint-config';
|
|
65
53
|
|
|
66
|
-
|
|
54
|
+
const eslintConfig = perfectiveEslintConfig();
|
|
55
|
+
|
|
56
|
+
export default eslintConfig;
|
|
67
57
|
```
|
|
68
58
|
|
|
69
|
-
3. Install optional peer dependencies
|
|
59
|
+
3. _Optional_ Install optional peer dependencies to add tool-specific linting rules.
|
|
70
60
|
|
|
71
61
|
```bash
|
|
72
62
|
npm install --save-dev \
|
|
73
|
-
@smarttools/eslint-plugin-rxjs \
|
|
74
63
|
eslint-plugin-cypress \
|
|
75
64
|
eslint-plugin-jest \
|
|
76
65
|
eslint-plugin-jest-dom \
|
|
66
|
+
eslint-plugin-rxjs-x \
|
|
77
67
|
eslint-plugin-testing-library
|
|
78
68
|
```
|
|
79
69
|
|
|
80
|
-
|
|
81
|
-
if the dependency is installed.
|
|
70
|
+
Import configurations to `eslint.config.js`.
|
|
82
71
|
|
|
83
|
-
|
|
72
|
+
```javascript
|
|
73
|
+
import { perfectiveEslintConfig } from '@perfective/eslint-config';
|
|
74
|
+
|
|
75
|
+
// Optional dependencies.
|
|
76
|
+
import { cypressConfig } from '@perfective/eslint-config/cypress';
|
|
77
|
+
import { jestConfig } from '@perfective/eslint-config/jest';
|
|
78
|
+
import { jestDomConfig } from '@perfective/eslint-config/jest-dom';
|
|
79
|
+
import { rxjsConfig } from '@perfective/eslint-config/rxjs';
|
|
80
|
+
import { testingLibraryConfig } from '@perfective/eslint-config/testing-library';
|
|
81
|
+
|
|
82
|
+
const eslintConfig = perfectiveEslintConfig([
|
|
83
|
+
cypressConfig,
|
|
84
|
+
jestConfig,
|
|
85
|
+
jestDomConfig,
|
|
86
|
+
rxjsConfig,
|
|
87
|
+
testingLibraryConfig,
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
export default eslintConfig;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
4. _Optional_ Customize configuration rules in `eslint.config.js`
|
|
84
94
|
|
|
85
95
|
```javascript
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
import { perfectiveEslintConfig, typescriptFiles } from '@perfective/eslint-config';
|
|
97
|
+
|
|
98
|
+
const eslintConfig = perfectiveEslintConfig([
|
|
99
|
+
// ...Optional configurations...
|
|
100
|
+
{
|
|
101
|
+
// These rules are overridden to all files
|
|
102
|
+
rules: {
|
|
103
|
+
'@stylistic/js/indent': ['warn', 2],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
// These rules are overridden to TypeScript files only
|
|
108
|
+
files: typescriptFiles,
|
|
109
|
+
rules: {
|
|
110
|
+
'@stylistic/ts/indent': ['warn', 2],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
export default eslintConfig;
|
|
101
116
|
```
|
|
117
|
+
|
|
118
|
+
Read full [`documentation`](https://github.com/perfective/eslint-config/blob/main/README.adoc) in the repo.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import eslintPluginArrayFunc from 'eslint-plugin-array-func';
|
|
2
|
+
export function arrayFuncConfig() {
|
|
3
|
+
return {
|
|
4
|
+
plugins: {
|
|
5
|
+
'array-func': eslintPluginArrayFunc
|
|
6
|
+
},
|
|
7
|
+
rules: {
|
|
8
|
+
'array-func/from-map': 'warn',
|
|
9
|
+
'array-func/no-unnecessary-this-arg': 'error',
|
|
10
|
+
'array-func/prefer-array-from': 'warn',
|
|
11
|
+
'array-func/avoid-reverse': 'warn',
|
|
12
|
+
'array-func/prefer-flat-map': 'off',
|
|
13
|
+
'array-func/prefer-flat': 'off'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Linter } from 'eslint';
|
|
2
|
+
import { Glob } from '../../linter/glob';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a flat config for `eslint-plugin-cypress` for a given list of files globs.
|
|
5
|
+
*
|
|
6
|
+
* Overrides some rules for `perfectiveEslintConfig` for compatibility with Cypress.
|
|
7
|
+
*
|
|
8
|
+
* @since v0.31.0
|
|
9
|
+
*/
|
|
10
|
+
export declare function cypressConfig(files?: Glob[]): Linter.Config;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import eslintPluginCypress from 'eslint-plugin-cypress/flat';
|
|
2
|
+
import { cypressFiles } from "../../linter/glob.js";
|
|
3
|
+
import { importNoExtraneousDependencies } from "../import/rules/no-extraneous-dependencies.js";
|
|
4
|
+
export function cypressConfig(files = [cypressFiles]) {
|
|
5
|
+
return {
|
|
6
|
+
files,
|
|
7
|
+
plugins: {
|
|
8
|
+
cypress: eslintPluginCypress
|
|
9
|
+
},
|
|
10
|
+
rules: Object.assign({
|
|
11
|
+
'cypress/assertion-before-screenshot': 'error',
|
|
12
|
+
'cypress/no-assigning-return-values': 'error',
|
|
13
|
+
'cypress/no-async-before': 'error',
|
|
14
|
+
'cypress/no-async-tests': 'error',
|
|
15
|
+
'cypress/no-chained-get': 'error',
|
|
16
|
+
'cypress/no-debug': 'error',
|
|
17
|
+
'cypress/no-force': 'error',
|
|
18
|
+
'cypress/no-pause': 'error',
|
|
19
|
+
'cypress/no-unnecessary-waiting': 'error',
|
|
20
|
+
'cypress/no-xpath': 'error',
|
|
21
|
+
'cypress/require-data-selectors': 'error',
|
|
22
|
+
'cypress/unsafe-to-chain-command': 'error'
|
|
23
|
+
}, perfectiveRules())
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function perfectiveRules() {
|
|
27
|
+
return {
|
|
28
|
+
'init-declarations': 'off',
|
|
29
|
+
'@typescript-eslint/init-declarations': 'off',
|
|
30
|
+
'import/no-extraneous-dependencies': ['error', importNoExtraneousDependencies({
|
|
31
|
+
devDependencies: [cypressFiles]
|
|
32
|
+
})],
|
|
33
|
+
'max-nested-callbacks': ['error', 4],
|
|
34
|
+
'new-cap': ['error', {
|
|
35
|
+
capIsNewExceptions: ['Given', 'When', 'Then', 'And', 'But', 'Before', 'After']
|
|
36
|
+
}]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cypressConfig } from './cypress-config';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cypressConfig } from "./cypress-config.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { eslintLayoutFormattingRules } from "./layout-formatting-rules.js";
|
|
2
|
+
import { eslintPossibleProblemsRules } from "./possible-problems-rules.js";
|
|
3
|
+
import { eslintSuggestionsRules } from "./suggestions-rules.js";
|
|
4
|
+
export function eslintConfig() {
|
|
5
|
+
return {
|
|
6
|
+
rules: Object.assign(Object.assign(Object.assign({}, eslintPossibleProblemsRules), eslintSuggestionsRules), eslintLayoutFormattingRules)
|
|
7
|
+
};
|
|
8
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const eslintLayoutFormattingRules = {
|
|
2
|
+
'array-bracket-newline': 'off',
|
|
3
|
+
'array-bracket-spacing': 'off',
|
|
4
|
+
'array-element-newline': 'off',
|
|
5
|
+
'arrow-parens': 'off',
|
|
6
|
+
'arrow-spacing': 'off',
|
|
7
|
+
'block-spacing': 'off',
|
|
8
|
+
'brace-style': 'off',
|
|
9
|
+
'comma-dangle': 'off',
|
|
10
|
+
'comma-spacing': 'off',
|
|
11
|
+
'comma-style': 'off',
|
|
12
|
+
'computed-property-spacing': 'off',
|
|
13
|
+
'dot-location': 'off',
|
|
14
|
+
'eol-last': 'off',
|
|
15
|
+
'func-call-spacing': 'off',
|
|
16
|
+
'function-call-argument-newline': 'off',
|
|
17
|
+
'function-paren-newline': 'off',
|
|
18
|
+
'generator-star-spacing': 'off',
|
|
19
|
+
'implicit-arrow-linebreak': 'off',
|
|
20
|
+
'indent': 'off',
|
|
21
|
+
'jsx-quotes': 'off',
|
|
22
|
+
'key-spacing': 'off',
|
|
23
|
+
'keyword-spacing': 'off',
|
|
24
|
+
'line-comment-position': 'off',
|
|
25
|
+
'linebreak-style': 'off',
|
|
26
|
+
'lines-around-comment': 'off',
|
|
27
|
+
'lines-between-class-members': 'off',
|
|
28
|
+
'max-len': 'off',
|
|
29
|
+
'max-statements-per-line': 'off',
|
|
30
|
+
'multiline-ternary': 'off',
|
|
31
|
+
'new-parens': 'off',
|
|
32
|
+
'newline-per-chained-call': 'off',
|
|
33
|
+
'no-extra-parens': 'off',
|
|
34
|
+
'no-mixed-spaces-and-tabs': 'off',
|
|
35
|
+
'no-multi-spaces': 'off',
|
|
36
|
+
'no-multiple-empty-lines': 'off',
|
|
37
|
+
'no-tabs': 'off',
|
|
38
|
+
'no-trailing-spaces': 'off',
|
|
39
|
+
'no-whitespace-before-property': 'off',
|
|
40
|
+
'nonblock-statement-body-position': 'off',
|
|
41
|
+
'object-curly-newline': 'off',
|
|
42
|
+
'object-curly-spacing': 'off',
|
|
43
|
+
'object-property-newline': 'off',
|
|
44
|
+
'operator-linebreak': 'off',
|
|
45
|
+
'padded-blocks': 'off',
|
|
46
|
+
'padding-line-between-statements': 'off',
|
|
47
|
+
'quotes': 'off',
|
|
48
|
+
'rest-spread-spacing': 'off',
|
|
49
|
+
'semi': 'off',
|
|
50
|
+
'semi-spacing': 'off',
|
|
51
|
+
'semi-style': 'off',
|
|
52
|
+
'space-before-blocks': 'off',
|
|
53
|
+
'space-before-function-paren': 'off',
|
|
54
|
+
'space-in-parens': 'off',
|
|
55
|
+
'space-infix-ops': 'off',
|
|
56
|
+
'space-unary-ops': 'off',
|
|
57
|
+
'switch-colon-spacing': 'off',
|
|
58
|
+
'template-curly-spacing': 'off',
|
|
59
|
+
'template-tag-spacing': 'off',
|
|
60
|
+
'unicode-bom': ['warn', 'never'],
|
|
61
|
+
'wrap-iife': 'off',
|
|
62
|
+
'wrap-regex': 'off',
|
|
63
|
+
'yield-star-spacing': 'off'
|
|
64
|
+
};
|