@perfective/eslint-config 0.28.0 → 0.29.1

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.
Files changed (56) hide show
  1. package/README.adoc +29 -31
  2. package/README.md +24 -4
  3. package/config/plugin.d.ts +0 -3
  4. package/config/plugin.js +0 -24
  5. package/config.d.ts +1 -1
  6. package/config.js +1 -4
  7. package/cypress.d.ts +1 -0
  8. package/cypress.js +58 -0
  9. package/index.d.ts +1734 -0
  10. package/index.js +2 -35
  11. package/jest-dom.d.ts +1 -0
  12. package/jest-dom.js +11 -0
  13. package/jest.d.ts +1 -0
  14. package/jest.js +24 -0
  15. package/package.json +49 -17
  16. package/rules/array-func/index.d.ts +14 -0
  17. package/rules/cypress/index.d.ts +21 -0
  18. package/rules/cypress/index.js +4 -1
  19. package/rules/eslint/index.d.ts +339 -0
  20. package/rules/eslint/layout-formatting.d.ts +64 -0
  21. package/rules/eslint/possible-problems.d.ts +96 -0
  22. package/rules/eslint/possible-problems.js +10 -2
  23. package/rules/eslint/suggestions.d.ts +181 -0
  24. package/rules/eslint/suggestions.js +3 -1
  25. package/rules/eslint-comments/best-practices.d.ts +8 -0
  26. package/rules/eslint-comments/index.d.ts +21 -0
  27. package/rules/eslint-comments/stylistic-issues.d.ts +9 -0
  28. package/rules/import/helpful-warnings.d.ts +10 -0
  29. package/rules/import/index.d.ts +78 -0
  30. package/rules/import/module-systems.d.ts +10 -0
  31. package/rules/import/static-analysis.d.ts +26 -0
  32. package/rules/import/style-guide.d.ts +33 -0
  33. package/rules/jest/index.d.ts +124 -0
  34. package/rules/jest/typescript-eslint.d.ts +5 -0
  35. package/rules/jest-dom/index.d.ts +32 -0
  36. package/rules/jsdoc/index.d.ts +134 -0
  37. package/rules/n/index.d.ts +66 -0
  38. package/rules/prefer-arrow/index.d.ts +14 -0
  39. package/rules/promise/index.d.ts +35 -0
  40. package/rules/rxjs/index.d.ts +60 -0
  41. package/rules/rxjs/index.js +41 -42
  42. package/rules/security/index.d.ts +22 -0
  43. package/rules/simple-import-sort/index.d.ts +10 -0
  44. package/rules/stylistic/js/index.d.ts +197 -0
  45. package/rules/stylistic/jsx/index.d.ts +81 -0
  46. package/rules/stylistic/plus/index.d.ts +14 -0
  47. package/rules/stylistic/ts/index.d.ts +135 -0
  48. package/rules/testing-library/index.d.ts +62 -0
  49. package/rules/typescript-eslint/extension-rules.d.ts +113 -0
  50. package/rules/typescript-eslint/index.d.ts +369 -0
  51. package/rules/typescript-eslint/supported-rules.d.ts +253 -0
  52. package/rules/unicorn/index.d.ts +178 -0
  53. package/rxjs.d.ts +1 -0
  54. package/rxjs.js +58 -0
  55. package/testing-library.d.ts +1 -0
  56. package/testing-library.js +11 -0
package/README.adoc CHANGED
@@ -61,35 +61,52 @@ npm install --save-dev \
61
61
  typescript-eslint
62
62
  ----
63
63
  +
64
+ . Require the configuration in your root `eslint.config.js`.
65
+ +
66
+ [source,javascript]
67
+ ----
68
+ const perfectiveEslintConfig = require('@perfective/eslint-config');
69
+
70
+ module.exports = perfectiveEslintConfig.default;
71
+ ----
72
+ +
73
+ . `*.d.ts` files and `dist` directories are ignored by the configuration.
74
+ `node_modules` and dot-files are ignored by the `eslint`.
75
+ If more directories or file types need to be ignored, see the
76
+ `link:https://eslint.org/docs/user-guide/configuring/ignoring-code#the-eslintignore-file[.eslintignore]` file docs.
77
+ +
64
78
  . Install optional peer dependencies that add linting rules for the tools you use.
65
79
  +
66
80
  [source,bash]
67
81
  ----
68
82
  npm install --save-dev \
83
+ @smarttools/eslint-plugin-rxjs \
69
84
  eslint-plugin-cypress \
70
85
  eslint-plugin-jest \
71
86
  eslint-plugin-jest-dom \
72
- eslint-plugin-rxjs \
73
87
  eslint-plugin-testing-library
74
88
  ----
75
89
  +
76
- The `@perfective/eslint-config` automatically includes rules for these plugins,
77
- if the dependency is installed.
78
- +
79
- . Require the configuration in your root `eslint.config.js`.
90
+ . Add optional configurations to your root `eslint.config.js`.
80
91
  +
81
92
  [source,javascript]
82
93
  ----
83
94
  const perfectiveEslintConfig = require('@perfective/eslint-config');
95
+ const perfectiveCypressConfig = require('@perfective/eslint-config/cypress');
96
+ const perfectiveJestConfig = require('@perfective/eslint-config/jest');
97
+ const perfectiveJestDomConfig = require('@perfective/eslint-config/jest-dom');
98
+ const perfectiveRxjsConfig = require('@perfective/eslint-config/rxjs');
99
+ const perfectiveTestingLibraryConfig = require('@perfective/eslint-config/testing-library');
84
100
 
85
- module.exports = perfectiveEslintConfig.default;
101
+ module.exports = [
102
+ ...perfectiveEslintConfig.default,
103
+ perfectiveCypressConfig.cypressConfig(),
104
+ perfectiveJestConfig.jestConfig(),
105
+ perfectiveJestDomConfig.jestDomConfig(),
106
+ perfectiveRxjsConfig.rxjsConfig(),
107
+ perfectiveTestingLibraryConfig.testingLibrarysConfig(),
108
+ ];
86
109
  ----
87
- +
88
- . `*.d.ts` files and `dist` directories are ignored by the configuration.
89
- `node_modules` and dot-files are ignored by the `eslint`.
90
- If more directories or file types need to be ignored, see the
91
- `link:https://eslint.org/docs/user-guide/configuring/ignoring-code#the-eslintignore-file[.eslintignore]` file docs.
92
-
93
110
 
94
111
  == Rules Configuration Extension Functions
95
112
 
@@ -135,22 +152,3 @@ for the `simple-import-sort/imports` rule.
135
152
  * `unicornPreventAbbreviations(replacements, options)`
136
153
  — extends and overrides the list of `replacements`
137
154
  and `options` for the `unicorn/prevent-abbreviation` rule.
138
-
139
-
140
- == Internals
141
-
142
- The rules for each plugin are described in the `./src/rules/{plugin}` subdirectories,
143
- where the `{plugin}` is the name of the plugin (after the `eslint-plugin-` prefix).
144
- Each configuration is exported from the `./index.ts` file
145
- and is organized as a partial ESLint config.
146
- It should contain the plugin name and the list of the rules, sorted alphabetically.
147
- When a plugin's documentation groups rules,
148
- each group is configured in a separate file
149
- and then extended in the `./index.ts` file.
150
-
151
- The final configuration extends each plugin configuration on a file-type basis.
152
-
153
-
154
- == Roadmap
155
-
156
- * Add the `@perfective/eslint-plugin` with the rules for working with the `@perfective` packages.
package/README.md CHANGED
@@ -59,24 +59,44 @@ from issues that will be fixed automatically.
59
59
  typescript-eslint
60
60
  ```
61
61
 
62
- 2. Install optional peer dependencies that add linting rules for the tools you use.
62
+ 2. Require the configuration in your root `eslint.config.js`.
63
+
64
+ ```javascript
65
+ const perfectiveEslintConfig = require('@perfective/eslint-config');
66
+
67
+ module.exports = perfectiveEslintConfig.default;
68
+ ```
69
+
70
+ 3. Install optional peer dependencies that add linting rules for the tools you use.
63
71
 
64
72
  ```bash
65
73
  npm install --save-dev \
74
+ @smarttools/eslint-plugin-rxjs \
66
75
  eslint-plugin-cypress \
67
76
  eslint-plugin-jest \
68
77
  eslint-plugin-jest-dom \
69
- eslint-plugin-rxjs \
70
78
  eslint-plugin-testing-library
71
79
  ```
72
80
 
73
81
  The `@perfective/eslint-config` automatically includes rules for these plugins,
74
82
  if the dependency is installed.
75
83
 
76
- 3. Require the configuration in your root `eslint.config.js`.
84
+ 4. Add optional configurations to your root `eslint.config.js`.
77
85
 
78
86
  ```javascript
79
87
  const perfectiveEslintConfig = require('@perfective/eslint-config');
88
+ const perfectiveCypressConfig = require('@perfective/eslint-config/cypress');
89
+ const perfectiveJestConfig = require('@perfective/eslint-config/jest');
90
+ const perfectiveJestDomConfig = require('@perfective/eslint-config/jest-dom');
91
+ const perfectiveRxjsConfig = require('@perfective/eslint-config/rxjs');
92
+ const perfectiveTestingLibraryConfig = require('@perfective/eslint-config/testing-library');
80
93
 
81
- module.exports = perfectiveEslintConfig.default;
94
+ module.exports = [
95
+ ...perfectiveEslintConfig.default,
96
+ perfectiveCypressConfig.cypressConfig(),
97
+ perfectiveJestConfig.jestConfig(),
98
+ perfectiveJestDomConfig.jestDomConfig(),
99
+ perfectiveRxjsConfig.rxjsConfig(),
100
+ perfectiveTestingLibraryConfig.testingLibrarysConfig(),
101
+ ];
82
102
  ```
@@ -1,5 +1,2 @@
1
- export declare function optionalConfig(plugin: string, rules: Record<string, unknown>): Record<string, unknown>;
2
- export declare function optionalOverrides(plugin: string, overrides: Record<string, unknown>): Record<string, unknown> | null;
3
- export declare function optionalRules(plugin: string): string | null;
4
1
  export declare function optionalRule(rule: string, config: unknown): Record<string, unknown>;
5
2
  export declare function hasEslintPlugin(plugin: string): boolean;
package/config/plugin.js CHANGED
@@ -1,32 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optionalConfig = optionalConfig;
4
- exports.optionalOverrides = optionalOverrides;
5
- exports.optionalRules = optionalRules;
6
3
  exports.optionalRule = optionalRule;
7
4
  exports.hasEslintPlugin = hasEslintPlugin;
8
5
  const node_1 = require("./node");
9
- function optionalConfig(plugin, rules) {
10
- if (hasEslintPlugin(plugin)) {
11
- return {
12
- plugins: [plugin],
13
- rules,
14
- };
15
- }
16
- return {};
17
- }
18
- function optionalOverrides(plugin, overrides) {
19
- if (hasEslintPlugin(plugin)) {
20
- return overrides;
21
- }
22
- return null;
23
- }
24
- function optionalRules(plugin) {
25
- if (hasEslintPlugin(plugin)) {
26
- return `./rules/${plugin.replace(/^@/u, '')}`;
27
- }
28
- return null;
29
- }
30
6
  function optionalRule(rule, config) {
31
7
  const plugin = pluginOfRule(rule);
32
8
  if (plugin === null) {
package/config.d.ts CHANGED
@@ -1 +1 @@
1
- export { hasEslintPlugin, optionalConfig, optionalOverrides, optionalRule, optionalRules, } from './config/plugin';
1
+ export { hasEslintPlugin, optionalRule, } from './config/plugin';
package/config.js CHANGED
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optionalRules = exports.optionalRule = exports.optionalOverrides = exports.optionalConfig = exports.hasEslintPlugin = void 0;
3
+ exports.optionalRule = exports.hasEslintPlugin = void 0;
4
4
  var plugin_1 = require("./config/plugin");
5
5
  Object.defineProperty(exports, "hasEslintPlugin", { enumerable: true, get: function () { return plugin_1.hasEslintPlugin; } });
6
- Object.defineProperty(exports, "optionalConfig", { enumerable: true, get: function () { return plugin_1.optionalConfig; } });
7
- Object.defineProperty(exports, "optionalOverrides", { enumerable: true, get: function () { return plugin_1.optionalOverrides; } });
8
6
  Object.defineProperty(exports, "optionalRule", { enumerable: true, get: function () { return plugin_1.optionalRule; } });
9
- Object.defineProperty(exports, "optionalRules", { enumerable: true, get: function () { return plugin_1.optionalRules; } });
package/cypress.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function cypressConfig(files?: string[]): Record<string, unknown>;
package/cypress.js ADDED
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.cypressConfig = cypressConfig;
37
+ const tsEslint = __importStar(require("typescript-eslint"));
38
+ const cypress_1 = require("./rules/cypress");
39
+ const no_extraneous_dependencies_1 = require("./rules/import/rules/no-extraneous-dependencies");
40
+ function cypressConfig(files = ['cypress/**/*.[jt]s']) {
41
+ return {
42
+ files,
43
+ languageOptions: Object.assign(Object.assign({}, cypress_1.cypressOptionalConfig.languageOptions), { parser: tsEslint.parser, parserOptions: {
44
+ ecmaVersion: 6,
45
+ ecmaFeatures: {
46
+ globalReturn: false,
47
+ impliedStrict: true,
48
+ },
49
+ sourceType: 'module',
50
+ project: './tsconfig.json',
51
+ warnOnUnsupportedTypeScriptVersion: true,
52
+ } }),
53
+ plugins: Object.assign({}, cypress_1.cypressOptionalConfig.plugins),
54
+ rules: Object.assign(Object.assign({}, cypress_1.cypressOptionalConfig.rules), { 'init-declarations': 'off', '@typescript-eslint/init-declarations': 'off', 'import/no-extraneous-dependencies': ['error', (0, no_extraneous_dependencies_1.cypressImportNoExtraneousDependencies)()], 'max-nested-callbacks': ['error', 4], 'new-cap': ['error', {
55
+ capIsNewExceptions: ['Given', 'When', 'Then', 'And', 'But', 'Before', 'After'],
56
+ }] }),
57
+ };
58
+ }