@aarongoldenthal/eslint-config-standard 32.0.0 → 33.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,18 +5,17 @@
5
5
  Custom ESLint configuration for all projects. Includes flat-config formatted
6
6
  configurations compatible with ESLint v9+ for the following:
7
7
 
8
- | Plugin Name | Config filename | Rule Prefix |
9
- | ------------------------------------------------- | -------------------------------------------------------------------------------- | --------------------- |
10
- | `eslint` | [`base-configs.js`](./base-configs.js) | |
11
- | `@eslint-community/eslint-plugin-eslint-comments` | [`eslint-comments-config.js`](./eslint-comments-config.js) | `comments` |
12
- | `eslint-plugin-jest` | [`jest-config.js`](./jest-config.js) | `jest` |
13
- | `eslint-plugin-jsdoc` | [`jsdoc-config.js`](./jsdoc-config.js) | `jsdoc` |
14
- | `eslint-plugin-n` | [`node-config.js`](./node-config.js) | `node` |
15
- | `eslint-plugin-playwright` | [`playwright-config.js`](./playwright-config.js) | `playwright` |
16
- | `eslint-plugin-promise` | [`promise-config.js`](./promise-config.js) | `promise` |
17
- | `eslint-plugin-sonarjs` | [`sonarjs-config.js`](./sonarjs-config.js) | `sonarjs`, `sonarjs2` |
18
- | `eslint-plugin-unicorn` | [`unicorn-configs.js`](./unicorn-configs.js), [`esm-config.js`](./esm-config.js) | `unicorn` |
19
- | `eslint-plugin-vitest` | [`vitest-config.js`](./vitest-config.js) | `vitest` |
8
+ | Plugin Name | Config filename | Rule Prefix |
9
+ | ------------------------------------------------- | -------------------------------------------------------------------------------- | ------------ |
10
+ | `eslint` | [`base-configs.js`](./base-configs.js) | none, `core` |
11
+ | `@eslint-community/eslint-plugin-eslint-comments` | [`eslint-comments-config.js`](./eslint-comments-config.js) | `comments` |
12
+ | `eslint-plugin-jest` | [`jest-config.js`](./jest-config.js) | `jest` |
13
+ | `eslint-plugin-jsdoc` | [`jsdoc-config.js`](./jsdoc-config.js) | `jsdoc` |
14
+ | `eslint-plugin-n` | [`node-config.js`](./node-config.js) | `node` |
15
+ | `eslint-plugin-playwright` | [`playwright-config.js`](./playwright-config.js) | `playwright` |
16
+ | `eslint-plugin-promise` | [`promise-config.js`](./promise-config.js) | `promise` |
17
+ | `eslint-plugin-unicorn` | [`unicorn-configs.js`](./unicorn-configs.js), [`esm-config.js`](./esm-config.js) | `unicorn` |
18
+ | `eslint-plugin-vitest` | [`vitest-config.js`](./vitest-config.js) | `vitest` |
20
19
 
21
20
  As flat configs, the package defines all required plugins/configurations as
22
21
  `dependencies`. Since flat config allows flexibility in the rule prefixes (that
@@ -26,10 +25,11 @@ flat config doesn't allow nested arrays of rules, file names that are singular
26
25
  export a single config object (for example `jsdoc-config.js`), and file names
27
26
  that are plural export an array of config objects (for example `base-configs.js`).
28
27
 
29
- The `sonarjs2` prefix has only one rule, `sonarjs2/cognitive-complexity`,
30
- that has a higher threshold. This provides a secondary check for cases where
31
- the lower threshold in the `sonarjs/cognitive-complexity` rule is
32
- disabled, which otherwise allows unbounded complexity.
28
+ The `core` prefix has only one rule, `core/complexity`, that has a higher threshold.
29
+ This provides a secondary check for cases where the lower threshold in the `complexity`
30
+ rule is disabled, which otherwise allows unbounded complexity. Since re-use of core
31
+ rules is an experimental capability, this must be enabled with environment variable
32
+ `ENABLE_ESLINT_CORE_RULE_DUPLICATES=true`.
33
33
 
34
34
  Most rule configurations are applicable to files matching `'**/*.{js,mjs,cjs}'`. The
35
35
  following configurations are exceptions and are applicable to files as noted:
package/base-configs.js CHANGED
@@ -1,14 +1,14 @@
1
1
  /* eslint-disable max-lines -- required given number of rules */
2
2
  'use strict';
3
3
 
4
- const complexityThreshold = 20;
4
+ const complexityThresholdLow = 5;
5
5
  const maxFunctionLinesThreshold = 30;
6
6
  const maxLinesThreshold = 300;
7
7
  const maxParametersThreshold = 4;
8
8
  const maxStatementsThreshold = 50;
9
9
  const nestedThreshold = 5;
10
10
 
11
- module.exports = [
11
+ const configs = [
12
12
  {
13
13
  files: ['**/*.{js,mjs,cjs}'],
14
14
  languageOptions: {
@@ -90,7 +90,10 @@ module.exports = [
90
90
  { ignoreConsecutiveComments: true, ignorePattern: 'nosemgrep' }
91
91
  ],
92
92
  'class-methods-use-this': 'error',
93
- complexity: ['error', complexityThreshold],
93
+ complexity: [
94
+ 'error',
95
+ { max: complexityThresholdLow, variant: 'modified' }
96
+ ],
94
97
  'consistent-return': 'error',
95
98
  // Disabled due to 'unicorn/no-this-assignment
96
99
  'consistent-this': 'off',
@@ -365,3 +368,30 @@ module.exports = [
365
368
  }
366
369
  }
367
370
  ];
371
+
372
+ if (process.env.ENABLE_ESLINT_CORE_RULE_DUPLICATES === 'true') {
373
+ /* eslint-disable-next-line node/global-require -- given the experimental
374
+ nature, only require when enabled */
375
+ const { builtinRules } = require('eslint/use-at-your-own-risk');
376
+ const complexity = builtinRules.get('complexity');
377
+
378
+ const complexityThresholdHigh = 15;
379
+ const coreDuplicateConfig = {
380
+ files: ['**/*.{js,mjs,cjs}'],
381
+ name: 'eslint core duplicates (all files)',
382
+ plugins: {
383
+ // Add plugin that duplicates the required rules
384
+ core: { rules: { complexity } }
385
+ },
386
+ rules: {
387
+ 'core/complexity': [
388
+ 'error',
389
+ { max: complexityThresholdHigh, variant: 'modified' }
390
+ ]
391
+ }
392
+ };
393
+
394
+ configs.push(coreDuplicateConfig);
395
+ }
396
+
397
+ module.exports = configs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarongoldenthal/eslint-config-standard",
3
- "version": "32.0.0",
3
+ "version": "33.0.0",
4
4
  "description": "Standard ESLint configuration settings",
5
5
  "scripts": {
6
6
  "hooks:pre-commit": "npm run lint && npm run prettier:check",
@@ -10,7 +10,8 @@
10
10
  "lint:md": "markdownlint-cli2 \"**/*.md\" \"#node_modules\"",
11
11
  "prettier:check": "prettier --check .",
12
12
  "prettier:fix": "prettier --write .",
13
- "test": "jest --ci"
13
+ "test": "jest --ci",
14
+ "test:no-coverage": "jest --ci --collectCoverage false"
14
15
  },
15
16
  "repository": {
16
17
  "type": "git",
@@ -33,21 +34,20 @@
33
34
  },
34
35
  "homepage": "https://gitlab.com/gitlab-ci-utils/eslint-config-standard",
35
36
  "dependencies": {
36
- "@eslint-community/eslint-plugin-eslint-comments": "4.4.0",
37
+ "@eslint-community/eslint-plugin-eslint-comments": "4.4.1",
37
38
  "@vitest/eslint-plugin": "1.1.7",
38
39
  "eslint-config-prettier": "9.1.0",
39
40
  "eslint-plugin-jest": "28.8.3",
40
- "eslint-plugin-jsdoc": "50.3.1",
41
- "eslint-plugin-n": "17.11.1",
42
- "eslint-plugin-playwright": "1.6.2",
41
+ "eslint-plugin-jsdoc": "50.4.3",
42
+ "eslint-plugin-n": "17.12.0",
43
+ "eslint-plugin-playwright": "2.0.0",
43
44
  "eslint-plugin-promise": "7.1.0",
44
- "eslint-plugin-sonarjs": "1.0.4",
45
45
  "eslint-plugin-unicorn": "56.0.0",
46
46
  "globals": "15.11.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@eslint/config-inspector": "0.5.4",
50
- "eslint": "9.12.0",
49
+ "@eslint/config-inspector": "0.5.6",
50
+ "eslint": "9.13.0",
51
51
  "jest": "29.7.0",
52
52
  "jest-junit": "16.0.0",
53
53
  "markdownlint-cli2": "0.14.0",
@@ -46,7 +46,9 @@ module.exports = {
46
46
  'playwright/prefer-equality-matcher': 'error',
47
47
  'playwright/prefer-hooks-in-order': 'error',
48
48
  'playwright/prefer-hooks-on-top': 'error',
49
+ 'playwright/prefer-locator': 'error',
49
50
  'playwright/prefer-lowercase-title': 'error',
51
+ 'playwright/prefer-native-locators': 'error',
50
52
  'playwright/prefer-strict-equal': 'error',
51
53
  'playwright/prefer-to-be': 'error',
52
54
  'playwright/prefer-to-contain': 'error',
@@ -5,7 +5,6 @@ const jsdocConfig = require('./jsdoc-config.js');
5
5
  const nodeConfig = require('./node-config.js');
6
6
  const playwrightConfig = require('./playwright-config.js');
7
7
  const promiseConfig = require('./promise-config.js');
8
- const sonarjsConfig = require('./sonarjs-config.js');
9
8
  const unicornConfigs = require('./unicorn-configs.js');
10
9
  const vitestConfig = require('./vitest-config.js');
11
10
  const baseConfigs = require('./base-configs.js');
@@ -18,7 +17,6 @@ module.exports = [
18
17
  nodeConfig,
19
18
  playwrightConfig,
20
19
  promiseConfig,
21
- sonarjsConfig,
22
20
  ...unicornConfigs,
23
21
  vitestConfig,
24
22
  ...baseConfigs,
package/recommended.js CHANGED
@@ -6,7 +6,6 @@ const jsdocConfig = require('./jsdoc-config.js');
6
6
  const nodeConfig = require('./node-config.js');
7
7
  const playwrightConfig = require('./playwright-config.js');
8
8
  const promiseConfig = require('./promise-config.js');
9
- const sonarjsConfig = require('./sonarjs-config.js');
10
9
  const unicornConfigs = require('./unicorn-configs.js');
11
10
  const baseConfigs = require('./base-configs.js');
12
11
  const prettierConfig = require('eslint-config-prettier');
@@ -18,7 +17,6 @@ module.exports = [
18
17
  nodeConfig,
19
18
  playwrightConfig,
20
19
  promiseConfig,
21
- sonarjsConfig,
22
20
  ...unicornConfigs,
23
21
  ...baseConfigs,
24
22
  { name: 'prettier (all files)', ...prettierConfig }
package/sonarjs-config.js DELETED
@@ -1,58 +0,0 @@
1
- 'use strict';
2
-
3
- const cognitiveComplexityThresholdLow = 5;
4
- const cognitiveComplexityThresholdHigh = 15;
5
- const maxSwitchCasesThreshold = 30;
6
- const noDuplicateStringThreshold = 3;
7
-
8
- const sonarjsPlugin = require('eslint-plugin-sonarjs');
9
-
10
- module.exports = {
11
- files: ['**/*.{js,mjs,cjs}'],
12
- name: 'sonarjs (all files)',
13
- plugins: { sonarjs: sonarjsPlugin, sonarjs2: sonarjsPlugin },
14
- rules: {
15
- 'sonarjs/cognitive-complexity': [
16
- 'error',
17
- cognitiveComplexityThresholdLow
18
- ],
19
- 'sonarjs/elseif-without-else': 'error',
20
- 'sonarjs/max-switch-cases': ['error', maxSwitchCasesThreshold],
21
- 'sonarjs/no-all-duplicated-branches': 'error',
22
- 'sonarjs/no-collapsible-if': 'error',
23
- 'sonarjs/no-collection-size-mischeck': 'error',
24
- 'sonarjs/no-duplicate-string': [
25
- 'error',
26
- { threshold: noDuplicateStringThreshold }
27
- ],
28
- 'sonarjs/no-duplicated-branches': 'error',
29
- 'sonarjs/no-element-overwrite': 'error',
30
- 'sonarjs/no-empty-collection': 'error',
31
- 'sonarjs/no-extra-arguments': 'error',
32
- 'sonarjs/no-gratuitous-expressions': 'error',
33
- 'sonarjs/no-identical-conditions': 'error',
34
- 'sonarjs/no-identical-expressions': 'error',
35
- 'sonarjs/no-identical-functions': 'error',
36
- 'sonarjs/no-ignored-return': 'off',
37
- 'sonarjs/no-inverted-boolean-check': 'error',
38
- 'sonarjs/no-nested-switch': 'error',
39
- 'sonarjs/no-nested-template-literals': 'error',
40
- 'sonarjs/no-one-iteration-loop': 'error',
41
- 'sonarjs/no-redundant-boolean': 'error',
42
- 'sonarjs/no-redundant-jump': 'error',
43
- 'sonarjs/no-same-line-conditional': 'error',
44
- 'sonarjs/no-small-switch': 'error',
45
- 'sonarjs/no-unused-collection': 'error',
46
- 'sonarjs/no-use-of-empty-return-value': 'error',
47
- 'sonarjs/no-useless-catch': 'error',
48
- 'sonarjs/non-existent-operator': 'error',
49
- 'sonarjs/prefer-immediate-return': 'error',
50
- 'sonarjs/prefer-object-literal': 'error',
51
- 'sonarjs/prefer-single-boolean-return': 'error',
52
- 'sonarjs/prefer-while': 'error',
53
- 'sonarjs2/cognitive-complexity': [
54
- 'error',
55
- cognitiveComplexityThresholdHigh
56
- ]
57
- }
58
- };