@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.
Files changed (200) hide show
  1. package/LICENSE +1 -1
  2. package/README.adoc +198 -67
  3. package/README.md +62 -45
  4. package/config/array-func/array-func-config.d.ts +2 -0
  5. package/config/array-func/array-func-config.js +16 -0
  6. package/config/cypress/cypress-config.d.ts +10 -0
  7. package/config/cypress/cypress-config.js +38 -0
  8. package/config/cypress/index.d.ts +1 -0
  9. package/config/cypress/index.js +1 -0
  10. package/config/eslint/eslint-config.d.ts +2 -0
  11. package/config/eslint/eslint-config.js +8 -0
  12. package/config/eslint/layout-formatting-rules.d.ts +2 -0
  13. package/config/eslint/layout-formatting-rules.js +64 -0
  14. package/config/eslint/possible-problems-rules.d.ts +2 -0
  15. package/config/eslint/possible-problems-rules.js +96 -0
  16. package/config/eslint/suggestions-rules.d.ts +2 -0
  17. package/config/eslint/suggestions-rules.js +181 -0
  18. package/config/eslint-comments/best-practices-rules.d.ts +2 -0
  19. package/config/eslint-comments/best-practices-rules.js +8 -0
  20. package/config/eslint-comments/eslint-comments-config.d.ts +2 -0
  21. package/config/eslint-comments/eslint-comments-config.js +11 -0
  22. package/config/eslint-comments/stylistic-issues-rules.d.ts +2 -0
  23. package/config/eslint-comments/stylistic-issues-rules.js +9 -0
  24. package/config/import/helpful-warnings-rules.d.ts +2 -0
  25. package/config/import/helpful-warnings-rules.js +11 -0
  26. package/config/import/import-config.d.ts +4 -0
  27. package/config/import/import-config.js +46 -0
  28. package/config/import/index.d.ts +1 -0
  29. package/config/import/index.js +1 -0
  30. package/config/import/module-systems-rules.d.ts +2 -0
  31. package/config/import/module-systems-rules.js +10 -0
  32. package/config/import/rules/no-extraneous-dependencies.d.ts +15 -0
  33. package/config/import/rules/no-extraneous-dependencies.js +8 -0
  34. package/config/import/static-analysis-rules.d.ts +2 -0
  35. package/config/import/static-analysis-rules.js +26 -0
  36. package/config/import/style-guide-rules.d.ts +2 -0
  37. package/config/import/style-guide-rules.js +33 -0
  38. package/config/jest/index.d.ts +1 -0
  39. package/config/jest/index.js +1 -0
  40. package/config/jest/jest-config.d.ts +8 -0
  41. package/config/jest/jest-config.js +128 -0
  42. package/config/jest/typescript-eslint-jest-rules.d.ts +2 -0
  43. package/config/jest/typescript-eslint-jest-rules.js +5 -0
  44. package/config/jest-dom/index.d.ts +1 -0
  45. package/config/jest-dom/index.js +1 -0
  46. package/config/jest-dom/jest-dom-config.d.ts +8 -0
  47. package/config/jest-dom/jest-dom-config.js +23 -0
  48. package/config/jsdoc/jsdoc-config.d.ts +3 -0
  49. package/config/jsdoc/jsdoc-config.js +179 -0
  50. package/config/node/node-config.d.ts +2 -0
  51. package/config/node/node-config.js +66 -0
  52. package/config/perfective-eslint-config.d.ts +6 -0
  53. package/config/perfective-eslint-config.js +45 -0
  54. package/config/prefer-arrow/prefer-arrow-config.d.ts +2 -0
  55. package/config/prefer-arrow/prefer-arrow-config.js +16 -0
  56. package/config/promise/promise-config.d.ts +2 -0
  57. package/config/promise/promise-config.js +37 -0
  58. package/config/rxjs/index.d.ts +1 -0
  59. package/config/rxjs/index.js +1 -0
  60. package/config/rxjs/rxjs-config.d.ts +8 -0
  61. package/config/rxjs/rxjs-config.js +67 -0
  62. package/config/security/security-config.d.ts +2 -0
  63. package/config/security/security-config.js +24 -0
  64. package/config/simple-import-sort/index.d.ts +1 -0
  65. package/config/simple-import-sort/index.js +1 -0
  66. package/config/simple-import-sort/rules/imports.d.ts +28 -0
  67. package/config/simple-import-sort/rules/imports.js +32 -0
  68. package/config/simple-import-sort/simple-import-sort-config.d.ts +2 -0
  69. package/config/simple-import-sort/simple-import-sort-config.js +13 -0
  70. package/config/stylistic/js/stylistic-js-config.d.ts +2 -0
  71. package/config/stylistic/js/stylistic-js-config.js +200 -0
  72. package/config/stylistic/jsx/stylistic-jsx-config.d.ts +2 -0
  73. package/config/stylistic/jsx/stylistic-jsx-config.js +87 -0
  74. package/config/stylistic/plus/stylistic-plus-config.d.ts +2 -0
  75. package/config/stylistic/plus/stylistic-plus-config.js +16 -0
  76. package/config/stylistic/ts/stylistic-ts-config.d.ts +2 -0
  77. package/config/stylistic/ts/stylistic-ts-config.js +141 -0
  78. package/config/testing-library/index.d.ts +1 -0
  79. package/config/testing-library/index.js +1 -0
  80. package/config/testing-library/testing-library-config.d.ts +8 -0
  81. package/config/testing-library/testing-library-config.js +45 -0
  82. package/config/typescript-eslint/extension-rules.d.ts +2 -0
  83. package/config/typescript-eslint/extension-rules.js +113 -0
  84. package/config/typescript-eslint/index.d.ts +1 -0
  85. package/config/typescript-eslint/index.js +1 -0
  86. package/{rules → config}/typescript-eslint/rules/typescript-eslint-naming-convention.d.ts +39 -0
  87. package/config/typescript-eslint/rules/typescript-eslint-naming-convention.js +26 -0
  88. package/config/typescript-eslint/supported-rules.d.ts +2 -0
  89. package/config/typescript-eslint/supported-rules.js +260 -0
  90. package/config/typescript-eslint/typescript-eslint-config.d.ts +2 -0
  91. package/config/typescript-eslint/typescript-eslint-config.js +15 -0
  92. package/config/unicorn/index.d.ts +1 -0
  93. package/config/unicorn/index.js +1 -0
  94. package/{rules → config}/unicorn/rules/prevent-abbreviations.d.ts +20 -0
  95. package/config/unicorn/rules/prevent-abbreviations.js +30 -0
  96. package/config/unicorn/unicorn-config.d.ts +2 -0
  97. package/config/unicorn/unicorn-config.js +185 -0
  98. package/index.d.ts +5 -1732
  99. package/index.js +5 -146
  100. package/linter/glob.d.ts +59 -0
  101. package/linter/glob.js +8 -0
  102. package/linter/language-options.d.ts +25 -0
  103. package/linter/language-options.js +45 -0
  104. package/linter/linter-config.d.ts +13 -0
  105. package/linter/linter-config.js +6 -0
  106. package/linter/node.d.ts +10 -0
  107. package/linter/node.js +7 -0
  108. package/linter/plugin.d.ts +15 -0
  109. package/linter/plugin.js +26 -0
  110. package/package.json +45 -45
  111. package/config/node.d.ts +0 -1
  112. package/config/node.js +0 -11
  113. package/config/plugin.d.ts +0 -2
  114. package/config/plugin.js +0 -30
  115. package/config.d.ts +0 -1
  116. package/config.js +0 -6
  117. package/cypress.d.ts +0 -1
  118. package/cypress.js +0 -56
  119. package/jest-dom.d.ts +0 -1
  120. package/jest-dom.js +0 -11
  121. package/jest.d.ts +0 -1
  122. package/jest.js +0 -24
  123. package/rules/array-func/index.d.ts +0 -14
  124. package/rules/array-func/index.js +0 -50
  125. package/rules/cypress/index.d.ts +0 -21
  126. package/rules/cypress/index.js +0 -57
  127. package/rules/eslint/index.d.ts +0 -339
  128. package/rules/eslint/index.js +0 -9
  129. package/rules/eslint/layout-formatting.d.ts +0 -64
  130. package/rules/eslint/layout-formatting.js +0 -67
  131. package/rules/eslint/possible-problems.d.ts +0 -96
  132. package/rules/eslint/possible-problems.js +0 -99
  133. package/rules/eslint/suggestions.d.ts +0 -181
  134. package/rules/eslint/suggestions.js +0 -182
  135. package/rules/eslint-comments/best-practices.d.ts +0 -8
  136. package/rules/eslint-comments/best-practices.js +0 -11
  137. package/rules/eslint-comments/index.d.ts +0 -21
  138. package/rules/eslint-comments/index.js +0 -45
  139. package/rules/eslint-comments/stylistic-issues.d.ts +0 -9
  140. package/rules/eslint-comments/stylistic-issues.js +0 -18
  141. package/rules/import/helpful-warnings.d.ts +0 -10
  142. package/rules/import/helpful-warnings.js +0 -14
  143. package/rules/import/index.d.ts +0 -78
  144. package/rules/import/index.js +0 -14
  145. package/rules/import/module-systems.d.ts +0 -10
  146. package/rules/import/module-systems.js +0 -13
  147. package/rules/import/rules/no-extraneous-dependencies.d.ts +0 -11
  148. package/rules/import/rules/no-extraneous-dependencies.js +0 -24
  149. package/rules/import/static-analysis.d.ts +0 -26
  150. package/rules/import/static-analysis.js +0 -29
  151. package/rules/import/style-guide.d.ts +0 -33
  152. package/rules/import/style-guide.js +0 -36
  153. package/rules/jest/index.d.ts +0 -124
  154. package/rules/jest/index.js +0 -72
  155. package/rules/jest/typescript-eslint.d.ts +0 -5
  156. package/rules/jest/typescript-eslint.js +0 -8
  157. package/rules/jest-dom/index.d.ts +0 -32
  158. package/rules/jest-dom/index.js +0 -55
  159. package/rules/jsdoc/index.d.ts +0 -134
  160. package/rules/jsdoc/index.js +0 -347
  161. package/rules/n/index.d.ts +0 -66
  162. package/rules/n/index.js +0 -98
  163. package/rules/prefer-arrow/index.d.ts +0 -14
  164. package/rules/prefer-arrow/index.js +0 -50
  165. package/rules/promise/index.d.ts +0 -35
  166. package/rules/promise/index.js +0 -73
  167. package/rules/rxjs/index.d.ts +0 -60
  168. package/rules/rxjs/index.js +0 -96
  169. package/rules/security/index.d.ts +0 -22
  170. package/rules/security/index.js +0 -58
  171. package/rules/simple-import-sort/index.d.ts +0 -10
  172. package/rules/simple-import-sort/index.js +0 -48
  173. package/rules/simple-import-sort/rules/imports.d.ts +0 -8
  174. package/rules/simple-import-sort/rules/imports.js +0 -46
  175. package/rules/stylistic/js/index.d.ts +0 -197
  176. package/rules/stylistic/js/index.js +0 -236
  177. package/rules/stylistic/jsx/index.d.ts +0 -81
  178. package/rules/stylistic/jsx/index.js +0 -117
  179. package/rules/stylistic/plus/index.d.ts +0 -14
  180. package/rules/stylistic/plus/index.js +0 -50
  181. package/rules/stylistic/ts/index.d.ts +0 -135
  182. package/rules/stylistic/ts/index.js +0 -169
  183. package/rules/testing-library/index.d.ts +0 -62
  184. package/rules/testing-library/index.js +0 -77
  185. package/rules/typescript-eslint/extension-rules.d.ts +0 -113
  186. package/rules/typescript-eslint/extension-rules.js +0 -116
  187. package/rules/typescript-eslint/index.d.ts +0 -369
  188. package/rules/typescript-eslint/index.js +0 -45
  189. package/rules/typescript-eslint/rules/typescript-eslint-naming-convention.js +0 -32
  190. package/rules/typescript-eslint/supported-rules.d.ts +0 -253
  191. package/rules/typescript-eslint/supported-rules.js +0 -319
  192. package/rules/unicorn/index.d.ts +0 -178
  193. package/rules/unicorn/index.js +0 -209
  194. package/rules/unicorn/rules/prevent-abbreviations.js +0 -8
  195. package/rules.d.ts +0 -4
  196. package/rules.js +0 -14
  197. package/rxjs.d.ts +0 -1
  198. package/rxjs.js +0 -58
  199. package/testing-library.d.ts +0 -1
  200. package/testing-library.js +0 -11
package/index.js CHANGED
@@ -1,146 +1,5 @@
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
- const tsEslint = __importStar(require("typescript-eslint"));
37
- const array_func_1 = require("./rules/array-func");
38
- const eslint_1 = require("./rules/eslint");
39
- const eslint_comments_1 = require("./rules/eslint-comments");
40
- const import_1 = require("./rules/import");
41
- const no_extraneous_dependencies_1 = require("./rules/import/rules/no-extraneous-dependencies");
42
- const jsdoc_1 = require("./rules/jsdoc");
43
- const n_1 = require("./rules/n");
44
- const prefer_arrow_1 = require("./rules/prefer-arrow");
45
- const promise_1 = require("./rules/promise");
46
- const security_1 = require("./rules/security");
47
- const simple_import_sort_1 = require("./rules/simple-import-sort");
48
- const js_1 = require("./rules/stylistic/js");
49
- const jsx_1 = require("./rules/stylistic/jsx");
50
- const plus_1 = require("./rules/stylistic/plus");
51
- const ts_1 = require("./rules/stylistic/ts");
52
- const typescript_eslint_1 = require("./rules/typescript-eslint");
53
- const unicorn_1 = require("./rules/unicorn");
54
- exports.default = [
55
- {
56
- ignores: ['**/*.d.ts', '**/dist'],
57
- },
58
- {
59
- files: ['**/*.[jt]s?(x)'],
60
- languageOptions: {
61
- sourceType: 'module',
62
- ecmaVersion: 'latest',
63
- parser: tsEslint.parser,
64
- parserOptions: {
65
- ecmaFeatures: {
66
- globalReturn: false,
67
- impliedStrict: true,
68
- },
69
- projectService: {
70
- allowDefaultProject: ['?(.)*.?(m|c)js'],
71
- },
72
- warnOnUnsupportedTypeScriptVersion: true,
73
- },
74
- },
75
- plugins: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, array_func_1.arrayFuncConfig.plugins), eslint_comments_1.eslintCommentsConfig.plugins), import_1.importConfig.plugins), jsdoc_1.jsdocConfig.plugins), n_1.nConfig.plugins), prefer_arrow_1.preferArrowConfig.plugins), promise_1.promiseConfig.plugins), security_1.securityConfig.plugins), simple_import_sort_1.simpleImportSortConfig.plugins), js_1.stylisticJsConfig.plugins), plus_1.stylisticPlusConfig.plugins), unicorn_1.unicornConfig.plugins),
76
- settings: {
77
- jsdoc: jsdoc_1.jsdocConfig.settings,
78
- },
79
- rules: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, array_func_1.arrayFuncConfig.rules), eslint_1.eslintConfig.rules), eslint_comments_1.eslintCommentsConfig.rules), import_1.importConfig.rules), jsdoc_1.jsdocConfig.rules), n_1.nConfig.rules), prefer_arrow_1.preferArrowConfig.rules), promise_1.promiseConfig.rules), security_1.securityConfig.rules), simple_import_sort_1.simpleImportSortConfig.rules), js_1.stylisticJsConfig.rules), plus_1.stylisticPlusConfig.rules), unicorn_1.unicornConfig.rules),
80
- },
81
- {
82
- files: ['**/*.js?(x)'],
83
- languageOptions: {
84
- sourceType: 'module',
85
- ecmaVersion: 'latest',
86
- parserOptions: {
87
- ecmaFeatures: {
88
- globalReturn: false,
89
- impliedStrict: true,
90
- },
91
- },
92
- },
93
- plugins: {},
94
- settings: {
95
- 'import/extensions': ['.js', '.jsx'],
96
- },
97
- rules: {
98
- 'import/no-commonjs': 'off',
99
- 'import/no-extraneous-dependencies': ['error', (0, no_extraneous_dependencies_1.jsImportNoExtraneousDependencies)()],
100
- 'import/unambiguous': 'off',
101
- 'jsdoc/no-types': 'off',
102
- 'jsdoc/no-undefined-types': 'off',
103
- 'jsdoc/require-param': 'error',
104
- 'jsdoc/require-param-type': 'error',
105
- 'jsdoc/require-returns': 'error',
106
- 'jsdoc/require-returns-type': 'error',
107
- },
108
- },
109
- {
110
- files: ['**/*.ts?(x)'],
111
- languageOptions: {
112
- sourceType: 'module',
113
- ecmaVersion: 'latest',
114
- parser: tsEslint.parser,
115
- parserOptions: {
116
- ecmaFeatures: {
117
- globalReturn: false,
118
- impliedStrict: true,
119
- },
120
- projectService: true,
121
- warnOnUnsupportedTypeScriptVersion: true,
122
- },
123
- },
124
- plugins: Object.assign(Object.assign({}, typescript_eslint_1.typescriptEslintConfig.plugins), ts_1.stylisticTsConfig.plugins),
125
- settings: {
126
- 'import/parsers': {
127
- '@typescript-eslint/parser': [
128
- '.ts',
129
- '.tsx',
130
- ],
131
- },
132
- 'import/resolver': {
133
- typescript: {
134
- alwaysTryTypes: true,
135
- project: './tsconfig.json',
136
- },
137
- },
138
- },
139
- rules: Object.assign(Object.assign({}, typescript_eslint_1.typescriptEslintConfig.rules), ts_1.stylisticTsConfig.rules),
140
- },
141
- {
142
- files: ['**/*.[jt]sx'],
143
- plugins: Object.assign({}, jsx_1.stylisticJsxConfig.plugins),
144
- rules: Object.assign({}, jsx_1.stylisticJsxConfig.rules),
145
- },
146
- ].filter(Boolean);
1
+ export { perfectiveEslintConfig } from "./config/perfective-eslint-config.js";
2
+ export { configurationFiles, cypressFiles, javascriptFiles, jestFiles, jsxFiles, tsxFiles, typescriptDeclarationFiles, typescriptFiles } from "./linter/glob.js";
3
+ export { javascriptLanguageOptions, languageOptions, typescriptLanguageOptions } from "./linter/language-options.js";
4
+ export { linterConfig } from "./linter/linter-config.js";
5
+ export { hasEslintPlugin, optionalRule } from "./linter/plugin.js";
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Nominal type for globs pattern string.
3
+ *
4
+ * @since v0.31.0
5
+ */
6
+ export type Glob = string;
7
+ /**
8
+ * A glob pattern for JSX files.
9
+ *
10
+ * @since v0.31.0
11
+ */
12
+ export declare const jsxFiles: Glob;
13
+ /**
14
+ * A list of glob patterns for JS and JSX files.
15
+ *
16
+ * @since v0.31.0
17
+ */
18
+ export declare const javascriptFiles: Glob[];
19
+ /**
20
+ * A glob pattern for TSX files.
21
+ *
22
+ * @since v0.31.0
23
+ */
24
+ export declare const tsxFiles: Glob;
25
+ /**
26
+ * A list of glob patterns for TypeScript source files.
27
+ *
28
+ * @since v0.31.0
29
+ */
30
+ export declare const typescriptFiles: Glob[];
31
+ /**
32
+ * A glob pattern for TypeScript declaration files.
33
+ *
34
+ * @since v0.31.0
35
+ */
36
+ export declare const typescriptDeclarationFiles: Glob;
37
+ /**
38
+ * A glob pattern for JavaScript tools configuration files.
39
+ *
40
+ * @since v0.31.0
41
+ */
42
+ export declare const configurationFiles: string[];
43
+ /**
44
+ * The default glob patterns Jest uses to find test files.
45
+ *
46
+ * @see https://jestjs.io/docs/configuration#testmatch-arraystring
47
+ *
48
+ * @since v0.31.0
49
+ */
50
+ export declare const jestFiles: Glob[];
51
+ /**
52
+ * The default glob pattern Cypress uses to load test files.
53
+ *
54
+ * @see https://docs.cypress.io/app/references/configuration#e2e
55
+ * @see https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests.html
56
+ *
57
+ * @since v0.31.0
58
+ */
59
+ export declare const cypressFiles: Glob;
package/linter/glob.js ADDED
@@ -0,0 +1,8 @@
1
+ export const jsxFiles = '**/*.jsx';
2
+ export const javascriptFiles = ['**/*.{js,cjs,mjs}', jsxFiles];
3
+ export const tsxFiles = '**/*.tsx';
4
+ export const typescriptFiles = ['**/*.{ts,cts,mts}', tsxFiles];
5
+ export const typescriptDeclarationFiles = '**/*.d.{ts,cts,mts}';
6
+ export const configurationFiles = ['**/.*.js', '**/*.config.js', '**/gulpfile.js'];
7
+ export const jestFiles = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
8
+ export const cypressFiles = 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}';
@@ -0,0 +1,25 @@
1
+ import { Linter } from 'eslint';
2
+ /**
3
+ * Creates ESLint `languageOptions` object for all files.
4
+ *
5
+ * - Uses TypeScript ESLint parser.
6
+ * - Allows parsing JavaScript files even if they are not allowed by TS config.
7
+ *
8
+ * @since v0.31.0
9
+ */
10
+ export declare function languageOptions(): Linter.LanguageOptions;
11
+ /**
12
+ * Creates ESLint `languageOptions` object for JavaScript files.
13
+ *
14
+ * @since v0.31.0
15
+ */
16
+ export declare function javascriptLanguageOptions(): Linter.LanguageOptions;
17
+ /**
18
+ * Creates ESLint `languageOptions` object for TypeScript files.
19
+ *
20
+ * - Uses TypeScript ESLint parser.
21
+ * - Does not allow JavaScript files.
22
+ *
23
+ * @since v0.31.0
24
+ */
25
+ export declare function typescriptLanguageOptions(): Linter.LanguageOptions;
@@ -0,0 +1,45 @@
1
+ import { parser as typescriptEslintParser } from 'typescript-eslint';
2
+ export function languageOptions() {
3
+ return {
4
+ sourceType: 'module',
5
+ ecmaVersion: 'latest',
6
+ parser: typescriptEslintParser,
7
+ parserOptions: {
8
+ ecmaFeatures: {
9
+ globalReturn: false,
10
+ impliedStrict: true
11
+ },
12
+ projectService: {
13
+ allowDefaultProject: ['?(.)*.?(m|c)js']
14
+ },
15
+ warnOnUnsupportedTypeScriptVersion: true
16
+ }
17
+ };
18
+ }
19
+ export function javascriptLanguageOptions() {
20
+ return {
21
+ sourceType: 'module',
22
+ ecmaVersion: 'latest',
23
+ parserOptions: {
24
+ ecmaFeatures: {
25
+ globalReturn: false,
26
+ impliedStrict: true
27
+ }
28
+ }
29
+ };
30
+ }
31
+ export function typescriptLanguageOptions() {
32
+ return {
33
+ sourceType: 'module',
34
+ ecmaVersion: 'latest',
35
+ parser: typescriptEslintParser,
36
+ parserOptions: {
37
+ ecmaFeatures: {
38
+ globalReturn: false,
39
+ impliedStrict: true
40
+ },
41
+ projectService: true,
42
+ warnOnUnsupportedTypeScriptVersion: true
43
+ }
44
+ };
45
+ }
@@ -0,0 +1,13 @@
1
+ import { Linter } from 'eslint';
2
+ /**
3
+ * An ESLint flat config or a function that returns one.
4
+ *
5
+ * @since v0.31.0
6
+ */
7
+ export type LinterConfig = Linter.Config | (() => Linter.Config);
8
+ /**
9
+ * A function to instantiate ESLint flat config.
10
+ *
11
+ * @since v0.31.0
12
+ */
13
+ export declare function linterConfig(config: LinterConfig): Linter.Config;
@@ -0,0 +1,6 @@
1
+ export function linterConfig(config) {
2
+ if (typeof config === 'function') {
3
+ return config();
4
+ }
5
+ return config;
6
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns true if a given `module` can be resolved in node_modules.
3
+ *
4
+ * A module does not have to be required directly by the package.json.
5
+ * The function returns true,
6
+ * even if it is installed as a dependency of another dependency but can be loaded by Node.js.
7
+ *
8
+ * @protected
9
+ */
10
+ export declare function hasNodeModule(module: string): boolean;
package/linter/node.js ADDED
@@ -0,0 +1,7 @@
1
+ export function hasNodeModule(module) {
2
+ try {
3
+ return Boolean(require.resolve(module));
4
+ } catch (_a) {
5
+ return false;
6
+ }
7
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Returns an object with rule as a key and its config as a value,
3
+ * if a given rule belongs to an installed ESLint plugin.
4
+ *
5
+ * Otherwise, returns an empty object.
6
+ *
7
+ * @since v0.21.0
8
+ */
9
+ export declare function optionalRule(rule: string, config: unknown): Record<string, unknown>;
10
+ /**
11
+ * Returns true if a given ESLint plugin exists.
12
+ *
13
+ * @since v0.21.0
14
+ */
15
+ export declare function hasEslintPlugin(plugin: string): boolean;
@@ -0,0 +1,26 @@
1
+ import { hasNodeModule } from "./node.js";
2
+ export function optionalRule(rule, config) {
3
+ const plugin = pluginOfRule(rule);
4
+ if (plugin === null) {
5
+ return {};
6
+ }
7
+ if (hasEslintPlugin(plugin)) {
8
+ return {
9
+ [rule]: config
10
+ };
11
+ }
12
+ return {};
13
+ }
14
+ export function hasEslintPlugin(plugin) {
15
+ if (plugin.startsWith('@')) {
16
+ return hasNodeModule(`${plugin}/eslint-plugin`);
17
+ }
18
+ return hasNodeModule(`eslint-plugin-${plugin}`);
19
+ }
20
+ function pluginOfRule(rule) {
21
+ const parts = rule.split('/');
22
+ if (parts.length > 1) {
23
+ return parts[0];
24
+ }
25
+ return null;
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perfective/eslint-config",
3
- "version": "0.29.2",
3
+ "version": "0.31.0",
4
4
  "description": "ESLint shareable rules configuration",
5
5
  "keywords": ["code quality", "code standard", "code style", "eslint", "eslint config", "lint", "perfective", "tslint", "tslint config", "typescript"],
6
6
  "author": "Andrey Mikheychik <a.mikheychik@gmail.com>",
@@ -9,32 +9,32 @@
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/perfective/eslint-config.git"
11
11
  },
12
+ "type": "module",
12
13
  "license": "MIT",
13
14
  "peerDependencies": {
14
- "@smarttools/eslint-plugin-rxjs": "^1.0.11",
15
- "@stylistic/eslint-plugin": "^2.12.1",
16
- "@stylistic/eslint-plugin-js": "^2.12.1",
17
- "@stylistic/eslint-plugin-jsx": "^2.12.1",
18
- "@stylistic/eslint-plugin-plus": "^2.12.1",
19
- "@stylistic/eslint-plugin-ts": "^2.12.1",
20
- "@typescript-eslint/utils": "^8.19.0",
21
- "eslint": "^9.17.0",
22
- "eslint-import-resolver-typescript": "^3.7.0",
23
- "eslint-plugin-array-func": "^4.0.0",
24
- "eslint-plugin-cypress": "^4.1.0",
25
- "eslint-plugin-eslint-comments": "^3.2.0",
15
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
16
+ "@stylistic/eslint-plugin": "^4.2.0",
17
+ "@stylistic/eslint-plugin-js": "^4.2.0",
18
+ "@stylistic/eslint-plugin-jsx": "^4.2.0",
19
+ "@stylistic/eslint-plugin-plus": "^4.2.0",
20
+ "@stylistic/eslint-plugin-ts": "^4.2.0",
21
+ "eslint": "^9.25.1",
22
+ "eslint-import-resolver-typescript": "^3.10.1",
23
+ "eslint-plugin-array-func": "^5.0.2",
24
+ "eslint-plugin-cypress": "^4.3.0",
26
25
  "eslint-plugin-import": "^2.31.0",
27
- "eslint-plugin-jest": "^28.10.0",
26
+ "eslint-plugin-jest": "^28.11.0",
28
27
  "eslint-plugin-jest-dom": "^5.5.0",
29
- "eslint-plugin-jsdoc": "^50.6.1",
30
- "eslint-plugin-n": "^17.15.1",
28
+ "eslint-plugin-jsdoc": "^50.6.11",
29
+ "eslint-plugin-n": "^17.17.0",
31
30
  "eslint-plugin-prefer-arrow": "^1.2.3",
32
31
  "eslint-plugin-promise": "^7.2.1",
32
+ "eslint-plugin-rxjs-x": "~0.7.2",
33
33
  "eslint-plugin-security": "^3.0.1",
34
34
  "eslint-plugin-simple-import-sort": "^12.1.1",
35
35
  "eslint-plugin-testing-library": "^7.1.1",
36
- "eslint-plugin-unicorn": "^56.0.1",
37
- "typescript-eslint": "^8.19.0"
36
+ "eslint-plugin-unicorn": "^59.0.0",
37
+ "typescript-eslint": "^8.31.1"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "eslint-plugin-cypress": {
@@ -53,7 +53,7 @@
53
53
  "optional": true
54
54
  }
55
55
  },
56
- "main": "./index.js",
56
+ "main": "./index.cjs",
57
57
  "module": "./index.js",
58
58
  "types": "./index.d.ts",
59
59
  "directories": {
@@ -63,43 +63,43 @@
63
63
  "exports": {
64
64
  ".": {
65
65
  "import": "./index.js",
66
- "require": "./index.js",
67
66
  "types": "./index.d.ts"
68
67
  },
69
- "./config": {
70
- "import": "./config.js",
71
- "require": "./config.js",
72
- "types": "./config.d.ts"
73
- },
74
- "./rules": {
75
- "import": "./rules.js",
76
- "require": "./rules.js",
77
- "types": "./rules.d.ts"
78
- },
79
68
  "./cypress": {
80
- "import": "./cypress.js",
81
- "require": "./cypress.js",
82
- "types": "./cypress.d.ts"
69
+ "import": "./config/cypress/index.js",
70
+ "types": "./config/cypress/index.d.ts"
71
+ },
72
+ "./import": {
73
+ "import": "./config/import/index.js",
74
+ "types": "./config/import/index.d.ts"
83
75
  },
84
76
  "./jest": {
85
- "import": "./jest.js",
86
- "require": "./jest.js",
87
- "types": "./jest.d.ts"
77
+ "import": "./config/jest/index.js",
78
+ "types": "./config/jest/index.d.ts"
88
79
  },
89
80
  "./jest-dom": {
90
- "import": "./jest-dom.js",
91
- "require": "./jest-dom.js",
92
- "types": "./jest-dom.d.ts"
81
+ "import": "./config/jest-dom/index.js",
82
+ "types": "./config/jest-dom/index.d.ts"
93
83
  },
94
84
  "./rxjs": {
95
- "import": "./rxjs.js",
96
- "require": "./rxjs.js",
97
- "types": "./rxjs.d.ts"
85
+ "import": "./config/rxjs/index.js",
86
+ "types": "./config/rxjs/index.d.ts"
87
+ },
88
+ "./simple-import-sort": {
89
+ "import": "./config/simple-import-sort/index.js",
90
+ "types": "./config/simple-import-sort/index.d.ts"
98
91
  },
99
92
  "./testing-library": {
100
- "import": "./testing-library.js",
101
- "require": "./testing-library.js",
102
- "types": "./testing-library.d.ts"
93
+ "import": "./config/testing-library/index.js",
94
+ "types": "./config/testing-library/index.d.ts"
95
+ },
96
+ "./typescript-eslint": {
97
+ "import": "./config/typescript-eslint/index.js",
98
+ "types": "./config/typescript-eslint/index.d.ts"
99
+ },
100
+ "./unicorn": {
101
+ "import": "./config/unicorn/index.js",
102
+ "types": "./config/unicorn/index.d.ts"
103
103
  }
104
104
  },
105
105
  "scripts": {}
package/config/node.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function hasNodeModule(module: string): boolean;
package/config/node.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasNodeModule = hasNodeModule;
4
- function hasNodeModule(module) {
5
- try {
6
- return Boolean(require.resolve(module));
7
- }
8
- catch (_a) {
9
- return false;
10
- }
11
- }
@@ -1,2 +0,0 @@
1
- export declare function optionalRule(rule: string, config: unknown): Record<string, unknown>;
2
- export declare function hasEslintPlugin(plugin: string): boolean;
package/config/plugin.js DELETED
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optionalRule = optionalRule;
4
- exports.hasEslintPlugin = hasEslintPlugin;
5
- const node_1 = require("./node");
6
- function optionalRule(rule, config) {
7
- const plugin = pluginOfRule(rule);
8
- if (plugin === null) {
9
- return {};
10
- }
11
- if (hasEslintPlugin(plugin)) {
12
- return {
13
- [rule]: config,
14
- };
15
- }
16
- return {};
17
- }
18
- function hasEslintPlugin(plugin) {
19
- if (plugin.startsWith('@')) {
20
- return (0, node_1.hasNodeModule)(`${plugin}/eslint-plugin`);
21
- }
22
- return (0, node_1.hasNodeModule)(`eslint-plugin-${plugin}`);
23
- }
24
- function pluginOfRule(rule) {
25
- const parts = rule.split('/');
26
- if (parts.length > 1) {
27
- return parts[0];
28
- }
29
- return null;
30
- }
package/config.d.ts DELETED
@@ -1 +0,0 @@
1
- export { hasEslintPlugin, optionalRule, } from './config/plugin';
package/config.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optionalRule = exports.hasEslintPlugin = void 0;
4
- var plugin_1 = require("./config/plugin");
5
- Object.defineProperty(exports, "hasEslintPlugin", { enumerable: true, get: function () { return plugin_1.hasEslintPlugin; } });
6
- Object.defineProperty(exports, "optionalRule", { enumerable: true, get: function () { return plugin_1.optionalRule; } });
package/cypress.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function cypressConfig(files?: string[]): Record<string, unknown>;
package/cypress.js DELETED
@@ -1,56 +0,0 @@
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({ sourceType: 'module', ecmaVersion: 'latest', parser: tsEslint.parser, parserOptions: {
44
- ecmaFeatures: {
45
- globalReturn: false,
46
- impliedStrict: true,
47
- },
48
- projectService: true,
49
- warnOnUnsupportedTypeScriptVersion: true,
50
- } }, cypress_1.cypressOptionalConfig.languageOptions),
51
- plugins: Object.assign({}, cypress_1.cypressOptionalConfig.plugins),
52
- 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', {
53
- capIsNewExceptions: ['Given', 'When', 'Then', 'And', 'But', 'Before', 'After'],
54
- }] }),
55
- };
56
- }
package/jest-dom.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function jestDomConfig(files?: string[]): Record<string, unknown>;
package/jest-dom.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jestDomConfig = jestDomConfig;
4
- const jest_dom_1 = require("./rules/jest-dom");
5
- function jestDomConfig(files = ['**/*.@(spec|test).[jt]s?(x)']) {
6
- return {
7
- files,
8
- plugins: jest_dom_1.jestDomConfig.plugins,
9
- rules: jest_dom_1.jestDomConfig.rules,
10
- };
11
- }
package/jest.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function jestConfig(files?: string[]): Record<string, unknown>;