@enormora/eslint-config-base-with-prettier 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,21 +1,32 @@
1
1
  {
2
2
  "author": "Mathias Schreck <schreck.mathias@gmail.com>",
3
3
  "contributors": [
4
- "Christian Rackerseder <github@echooff.de>"
4
+ {
5
+ "email": "github@echooff.de",
6
+ "name": "Christian Rackerseder"
7
+ }
5
8
  ],
6
9
  "dependencies": {
10
+ "@ben_12/eslint-simple-parser": "0.1.0",
7
11
  "@cspell/eslint-plugin": "10.0.1",
8
12
  "@eslint-community/eslint-plugin-eslint-comments": "4.7.2",
13
+ "@eslint/markdown": "8.0.2",
9
14
  "@stylistic/eslint-plugin": "5.10.0",
10
15
  "eslint-plugin-array-func": "5.1.1",
11
16
  "eslint-plugin-destructuring": "2.2.1",
12
17
  "eslint-plugin-import-x": "4.16.2",
18
+ "eslint-plugin-json-schema-validator": "6.2.0",
19
+ "eslint-plugin-markdown-links": "0.9.0",
20
+ "eslint-plugin-markdown-preferences": "0.41.1",
13
21
  "eslint-plugin-no-barrel-files": "1.3.1",
14
22
  "eslint-plugin-no-secrets": "2.3.3",
23
+ "eslint-plugin-package-json": "1.3.0",
15
24
  "eslint-plugin-prettier": "5.5.6",
16
25
  "eslint-plugin-promise": "7.3.0",
26
+ "eslint-plugin-regexp": "3.1.0",
17
27
  "eslint-plugin-sonarjs": "4.0.3",
18
- "eslint-plugin-unicorn": "64.0.0"
28
+ "eslint-plugin-unicorn": "64.0.0",
29
+ "jsonc-eslint-parser": "3.1.0"
19
30
  },
20
31
  "description": "Enormora’s ESLint base configuration formatted with prettier",
21
32
  "exports": {
@@ -39,5 +50,5 @@
39
50
  "./rule-sets/restricted-syntax.js"
40
51
  ],
41
52
  "type": "module",
42
- "version": "0.0.3"
53
+ "version": "0.0.5"
43
54
  }
@@ -9,7 +9,8 @@ import {
9
9
  noClassDeclarationRestriction,
10
10
  noEmptyFunctionBodyRestriction,
11
11
  noInOperatorRestriction,
12
- noSwitchStatementRestriction
12
+ noSwitchStatementRestriction,
13
+ noUnnecessaryArrowFunctionRestriction
13
14
  } from '../../rule-sets/restricted-syntax.js';
14
15
  import { stylisticRuleSet } from '../../rule-sets/stylistic.js';
15
16
 
@@ -17,7 +18,8 @@ const restrictedSyntaxPlugin = createRestrictedSyntaxPlugin([
17
18
  'no-class-declaration',
18
19
  'no-switch-statement',
19
20
  'no-empty-function-body',
20
- 'no-in-operator'
21
+ 'no-in-operator',
22
+ 'no-unnecessary-arrow-function'
21
23
  ]);
22
24
 
23
25
  export const cspellSpellcheckerOptions = {
@@ -156,6 +158,7 @@ export const baseSharedConfig = {
156
158
  'restricted-syntax/no-switch-statement': [ 'error', noSwitchStatementRestriction ],
157
159
  'restricted-syntax/no-empty-function-body': [ 'error', noEmptyFunctionBodyRestriction ],
158
160
  'restricted-syntax/no-in-operator': [ 'error', noInOperatorRestriction ],
161
+ 'restricted-syntax/no-unnecessary-arrow-function': [ 'error', noUnnecessaryArrowFunctionRestriction ],
159
162
  'no-return-assign': [ 'error', 'always' ],
160
163
  'no-self-assign': [ 'error', { props: true } ],
161
164
  'no-self-compare': 'error',
@@ -278,12 +281,7 @@ export const baseSharedConfig = {
278
281
  'object-shorthand': [ 'error', 'always' ],
279
282
  'one-var': [ 'error', 'never' ],
280
283
  'operator-assignment': [ 'error', 'always' ],
281
- 'prefer-arrow-callback': [
282
- 'error',
283
- {
284
- allowNamedFunctions: true
285
- }
286
- ],
284
+ 'prefer-arrow-callback': 'off',
287
285
  'prefer-rest-params': 'error',
288
286
  radix: 'error',
289
287
  'id-match': 'off',
@@ -332,7 +330,7 @@ export const baseSharedConfig = {
332
330
  'require-await': 'off',
333
331
  'sort-keys': 'off',
334
332
  'symbol-description': 'error',
335
- 'for-direction': 'off',
333
+ 'for-direction': 'error',
336
334
  'getter-return': [
337
335
  'error',
338
336
  {
@@ -358,7 +356,7 @@ export const baseSharedConfig = {
358
356
  'no-script-url': 'off',
359
357
  'no-restricted-globals': 'off',
360
358
 
361
- 'grouped-accessor-pairs': 'off',
359
+ 'grouped-accessor-pairs': [ 'error', 'getBeforeSet' ],
362
360
  'no-constructor-return': 'error',
363
361
  'no-dupe-else-if': 'error',
364
362
  'no-setter-return': 'error',
@@ -368,7 +366,7 @@ export const baseSharedConfig = {
368
366
  'no-restricted-exports': 'off',
369
367
  'no-useless-backreference': 'error',
370
368
  'id-denylist': 'off',
371
- 'no-loss-of-precision': 'off',
369
+ 'no-loss-of-precision': 'error',
372
370
  'no-promise-executor-return': 'error',
373
371
  'no-unreachable-loop': 'error',
374
372
  'no-nonoctal-decimal-escape': 'error',
@@ -0,0 +1 @@
1
+ import { cspellSpellcheckerOptions } from './base-shared.js';
@@ -0,0 +1,98 @@
1
+ import markdownPlugin from '@eslint/markdown';
2
+ import markdownLinksPlugin from 'eslint-plugin-markdown-links';
3
+ import markdownPreferencesPlugin from 'eslint-plugin-markdown-preferences';
4
+
5
+ export const markdownLintPlugins = {
6
+ markdown: markdownPlugin,
7
+ 'markdown-links': markdownLinksPlugin,
8
+ 'markdown-preferences': markdownPreferencesPlugin
9
+ };
10
+
11
+ export const markdownLintRules = {
12
+ 'markdown/fenced-code-language': 'error',
13
+ 'markdown/fenced-code-meta': 'off',
14
+ 'markdown/heading-increment': 'error',
15
+ 'markdown/no-bare-urls': 'error',
16
+ 'markdown/no-duplicate-definitions': 'error',
17
+ 'markdown/no-duplicate-headings': 'error',
18
+ 'markdown/no-empty-definitions': 'error',
19
+ 'markdown/no-empty-images': 'error',
20
+ 'markdown/no-empty-links': 'error',
21
+ 'markdown/no-html': 'error',
22
+ 'markdown/no-invalid-label-refs': 'error',
23
+ 'markdown/no-missing-atx-heading-space': 'error',
24
+ 'markdown/no-missing-label-refs': 'error',
25
+ 'markdown/no-missing-link-fragments': 'error',
26
+ 'markdown/no-multiple-h1': 'error',
27
+ 'markdown/no-reference-like-urls': 'error',
28
+ 'markdown/no-reversed-media-syntax': 'error',
29
+ 'markdown/no-space-in-emphasis': 'error',
30
+ 'markdown/no-unused-definitions': 'error',
31
+ 'markdown/require-alt-text': 'error',
32
+ 'markdown/table-column-count': 'error',
33
+
34
+ // markdown-links: external network check is opt-in to keep CI deterministic;
35
+ // local-path and fragment checks are pure wins.
36
+ 'markdown-links/no-dead-urls': 'off',
37
+ 'markdown-links/no-missing-fragments': 'error',
38
+ 'markdown-links/no-missing-path': 'error',
39
+ 'markdown-links/no-self-destination': 'error',
40
+
41
+ // markdown-preferences: many rules overlap with the active markdown formatter (dprint or
42
+ // prettier, depending on which base preset is used). We enable only the 8 rules from this
43
+ // plugin's `recommended` config (none of which fight either formatter) and explicitly turn
44
+ // the other 45 off. Override individually if a stricter style is desired.
45
+ 'markdown-preferences/atx-heading-closing-sequence': 'off',
46
+ 'markdown-preferences/atx-heading-closing-sequence-length': 'off',
47
+ 'markdown-preferences/blockquote-marker-alignment': 'error',
48
+ 'markdown-preferences/bullet-list-marker-style': 'off',
49
+ 'markdown-preferences/canonical-code-block-language': 'off',
50
+ 'markdown-preferences/code-fence-length': 'off',
51
+ 'markdown-preferences/code-fence-spacing': 'off',
52
+ 'markdown-preferences/code-fence-style': 'off',
53
+ 'markdown-preferences/custom-container-marker-spacing': 'off',
54
+ 'markdown-preferences/definitions-last': 'off',
55
+ 'markdown-preferences/emoji-notation': 'off',
56
+ 'markdown-preferences/emphasis-delimiters-style': 'off',
57
+ 'markdown-preferences/hard-linebreak-style': 'error',
58
+ 'markdown-preferences/heading-casing': 'off',
59
+ 'markdown-preferences/indent': 'off',
60
+ 'markdown-preferences/level1-heading-style': 'off',
61
+ 'markdown-preferences/level2-heading-style': 'off',
62
+ 'markdown-preferences/link-bracket-newline': 'off',
63
+ 'markdown-preferences/link-bracket-spacing': 'off',
64
+ 'markdown-preferences/link-destination-style': 'off',
65
+ 'markdown-preferences/link-paren-newline': 'off',
66
+ 'markdown-preferences/link-paren-spacing': 'off',
67
+ 'markdown-preferences/link-title-style': 'off',
68
+ 'markdown-preferences/list-marker-alignment': 'error',
69
+ 'markdown-preferences/max-len': 'off',
70
+ 'markdown-preferences/no-heading-trailing-punctuation': 'off',
71
+ 'markdown-preferences/no-implicit-block-closing': 'error',
72
+ 'markdown-preferences/no-laziness-blockquotes': 'error',
73
+ 'markdown-preferences/no-multi-spaces': 'off',
74
+ 'markdown-preferences/no-multiple-empty-lines': 'off',
75
+ 'markdown-preferences/no-tabs': 'off',
76
+ 'markdown-preferences/no-text-backslash-linebreak': 'error',
77
+ 'markdown-preferences/no-trailing-spaces': 'off',
78
+ 'markdown-preferences/ordered-list-marker-sequence': 'off',
79
+ 'markdown-preferences/ordered-list-marker-start': 'off',
80
+ 'markdown-preferences/ordered-list-marker-style': 'off',
81
+ 'markdown-preferences/padded-custom-containers': 'off',
82
+ 'markdown-preferences/padding-line-between-blocks': 'off',
83
+ 'markdown-preferences/prefer-autolinks': 'error',
84
+ 'markdown-preferences/prefer-fenced-code-blocks': 'error',
85
+ 'markdown-preferences/prefer-inline-code-words': 'off',
86
+ 'markdown-preferences/prefer-link-reference-definitions': 'off',
87
+ 'markdown-preferences/prefer-linked-words': 'off',
88
+ 'markdown-preferences/setext-heading-underline-length': 'off',
89
+ 'markdown-preferences/sort-definitions': 'off',
90
+ 'markdown-preferences/strikethrough-delimiters-style': 'off',
91
+ 'markdown-preferences/table-header-casing': 'off',
92
+ 'markdown-preferences/table-leading-trailing-pipes': 'off',
93
+ 'markdown-preferences/table-pipe-alignment': 'off',
94
+ 'markdown-preferences/table-pipe-spacing': 'off',
95
+ 'markdown-preferences/thematic-break-character-style': 'off',
96
+ 'markdown-preferences/thematic-break-length': 'off',
97
+ 'markdown-preferences/thematic-break-sequence-pattern': 'off'
98
+ };
@@ -0,0 +1,114 @@
1
+ import jsonSchemaValidatorPlugin from 'eslint-plugin-json-schema-validator';
2
+ import packageJsonPlugin from 'eslint-plugin-package-json';
3
+ import * as jsoncParser from 'jsonc-eslint-parser';
4
+
5
+ export const packageJsonConfig = {
6
+ files: [ '**/package.json' ],
7
+ languageOptions: { parser: jsoncParser },
8
+ plugins: {
9
+ 'package-json': packageJsonPlugin,
10
+ 'json-schema-validator': jsonSchemaValidatorPlugin
11
+ },
12
+ rules: {
13
+ 'package-json/no-empty-fields': 'error',
14
+ 'package-json/no-redundant-files': 'error',
15
+ 'package-json/no-redundant-publishConfig': 'error',
16
+ 'package-json/repository-shorthand': 'error',
17
+ 'package-json/restrict-private-properties': 'error',
18
+ 'package-json/scripts-name-casing': 'error',
19
+ 'package-json/sort-collections': 'error',
20
+ 'package-json/unique-dependencies': 'error',
21
+ 'package-json/valid-author': 'error',
22
+ 'package-json/valid-bin': 'error',
23
+ 'package-json/valid-browser': 'error',
24
+ 'package-json/valid-bugs': 'error',
25
+ 'package-json/valid-bundleDependencies': 'error',
26
+ 'package-json/valid-config': 'error',
27
+ 'package-json/valid-contributors': 'error',
28
+ 'package-json/valid-cpu': 'error',
29
+ 'package-json/valid-dependencies': 'error',
30
+ 'package-json/valid-description': 'error',
31
+ 'package-json/valid-devDependencies': 'error',
32
+ 'package-json/valid-devEngines': 'error',
33
+ 'package-json/valid-directories': 'error',
34
+ 'package-json/valid-engines': 'error',
35
+ 'package-json/valid-exports': 'error',
36
+ 'package-json/valid-files': 'error',
37
+ 'package-json/valid-funding': 'error',
38
+ 'package-json/valid-gypfile': 'error',
39
+ 'package-json/valid-homepage': 'error',
40
+ 'package-json/valid-keywords': 'error',
41
+ 'package-json/valid-libc': 'error',
42
+ 'package-json/valid-license': 'error',
43
+ 'package-json/valid-main': 'error',
44
+ 'package-json/valid-man': 'error',
45
+ 'package-json/valid-module': 'error',
46
+ 'package-json/valid-name': 'error',
47
+ 'package-json/valid-optionalDependencies': 'error',
48
+ 'package-json/valid-os': 'error',
49
+ 'package-json/valid-packageManager': 'error',
50
+ 'package-json/valid-peerDependencies': 'error',
51
+ 'package-json/valid-peerDependenciesMeta': 'error',
52
+ 'package-json/valid-peerDependenciesMeta-relationship': 'error',
53
+ 'package-json/valid-private': 'error',
54
+ 'package-json/valid-publishConfig': 'error',
55
+ 'package-json/valid-repository': 'error',
56
+ 'package-json/valid-repository-directory': 'error',
57
+ 'package-json/valid-scripts': 'error',
58
+ 'package-json/valid-sideEffects': 'error',
59
+ 'package-json/valid-type': 'error',
60
+ 'package-json/valid-version': 'error',
61
+ 'package-json/valid-workspaces': 'error',
62
+
63
+ // Too opinionated for a base preset — consumers can opt in.
64
+ 'package-json/bin-name-casing': 'off',
65
+ 'package-json/exports-subpaths-style': 'off',
66
+ 'package-json/no-local-dependencies': 'off',
67
+ 'package-json/order-properties': 'off',
68
+ 'package-json/require-attribution': 'off',
69
+ 'package-json/require-author': 'off',
70
+ 'package-json/require-bin': 'off',
71
+ 'package-json/require-browser': 'off',
72
+ 'package-json/require-bugs': 'off',
73
+ 'package-json/require-bundleDependencies': 'off',
74
+ 'package-json/require-config': 'off',
75
+ 'package-json/require-contributors': 'off',
76
+ 'package-json/require-cpu': 'off',
77
+ 'package-json/require-dependencies': 'off',
78
+ 'package-json/require-description': 'off',
79
+ 'package-json/require-devDependencies': 'off',
80
+ 'package-json/require-devEngines': 'off',
81
+ 'package-json/require-directories': 'off',
82
+ 'package-json/require-engines': 'off',
83
+ 'package-json/require-exports': 'off',
84
+ 'package-json/require-files': 'off',
85
+ 'package-json/require-funding': 'off',
86
+ 'package-json/require-gypfile': 'off',
87
+ 'package-json/require-homepage': 'off',
88
+ 'package-json/require-keywords': 'off',
89
+ 'package-json/require-libc': 'off',
90
+ 'package-json/require-license': 'off',
91
+ 'package-json/require-main': 'off',
92
+ 'package-json/require-man': 'off',
93
+ 'package-json/require-module': 'off',
94
+ 'package-json/require-name': 'off',
95
+ 'package-json/require-optionalDependencies': 'off',
96
+ 'package-json/require-os': 'off',
97
+ 'package-json/require-packageManager': 'off',
98
+ 'package-json/require-peerDependencies': 'off',
99
+ 'package-json/require-peerDependenciesMeta': 'off',
100
+ 'package-json/require-private': 'off',
101
+ 'package-json/require-publishConfig': 'off',
102
+ 'package-json/require-repository': 'off',
103
+ 'package-json/require-scripts': 'off',
104
+ 'package-json/require-sideEffects': 'off',
105
+ 'package-json/require-type': 'off',
106
+ 'package-json/require-types': 'off',
107
+ 'package-json/require-version': 'off',
108
+ 'package-json/restrict-dependency-ranges': 'off',
109
+ 'package-json/restrict-top-level-properties': 'off',
110
+ 'package-json/specify-peers-locally': 'off',
111
+
112
+ 'json-schema-validator/no-invalid': 'error'
113
+ }
114
+ };
@@ -1,7 +1,11 @@
1
+ import simpleParser from '@ben_12/eslint-simple-parser';
1
2
  import prettierPlugin from 'eslint-plugin-prettier';
2
3
  import { baseSharedConfig } from '../base/base-shared.js';
4
+ import { markdownLintPlugins, markdownLintRules } from '../base/markdown-lint-rules.js';
5
+ import { packageJsonConfig } from '../base/package-json.js';
3
6
 
4
- export const baseWithPrettierConfig = {
7
+ const baseJsConfig = {
8
+ files: [ '**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,vue}' ],
5
9
  ...baseSharedConfig,
6
10
  plugins: {
7
11
  ...baseSharedConfig.plugins,
@@ -10,6 +14,50 @@ export const baseWithPrettierConfig = {
10
14
  rules: {
11
15
  ...baseSharedConfig.rules,
12
16
 
13
- 'prettier/prettier': 'error'
17
+ 'prettier/prettier': 'error',
18
+
19
+ // Prettier owns TypeScript member delimiter formatting; the stylistic rule would only fight it.
20
+ '@stylistic/member-delimiter-style': 'off'
14
21
  }
15
22
  };
23
+
24
+ const prettierJsonConfig = {
25
+ files: [ '**/*.json' ],
26
+ languageOptions: { parser: simpleParser },
27
+ plugins: { prettier: prettierPlugin },
28
+ rules: { 'prettier/prettier': 'error' }
29
+ };
30
+
31
+ const prettierYamlConfig = {
32
+ files: [ '**/*.{yml,yaml}' ],
33
+ languageOptions: { parser: simpleParser },
34
+ plugins: { prettier: prettierPlugin },
35
+ rules: { 'prettier/prettier': 'error' }
36
+ };
37
+
38
+ const markdownConfig = {
39
+ files: [ '**/*.md' ],
40
+ plugins: {
41
+ ...markdownLintPlugins,
42
+ prettier: prettierPlugin
43
+ },
44
+ // See ../base/markdown.js for why this is pinned to commonmark instead of gfm.
45
+ language: 'markdown/commonmark',
46
+ rules: {
47
+ 'prettier/prettier': 'error',
48
+
49
+ ...markdownLintRules
50
+ }
51
+ };
52
+
53
+ export const baseWithPrettierConfig = [
54
+ baseJsConfig,
55
+ prettierJsonConfig,
56
+ packageJsonConfig,
57
+ markdownConfig,
58
+ prettierYamlConfig
59
+ ];
60
+
61
+ /* eslint-disable no-barrel-files/no-barrel-files -- expose cspell helper as public API so consumers can spread or call it when customizing */
62
+ export { withCspellWords } from '../base/cspell-config.js';
63
+ /* eslint-enable no-barrel-files/no-barrel-files -- end of public re-exports */
package/readme.md CHANGED
@@ -6,7 +6,11 @@ Drop-in alternative to [`@enormora/eslint-config-base`](../base/base.md) that fo
6
6
  [prettier](https://prettier.io/) instead of dprint.
7
7
 
8
8
  This preset is itself a base preset — pick this one **or** `@enormora/eslint-config-base`, never both. It contains the
9
- same set of lint rules as the regular base preset; the only difference is the formatter integration.
9
+ same set of lint rules as the regular base preset, including the semantic markdown linting stack
10
+ (`@eslint/markdown`, `eslint-plugin-markdown-links`, `eslint-plugin-markdown-preferences`) and the dedicated
11
+ `package.json` linting stack (`eslint-plugin-package-json`, `eslint-plugin-json-schema-validator`). The only
12
+ differences are the formatter integration and that TOML is not covered (prettier has no native TOML support; see
13
+ [Limitations](#limitations) below).
10
14
 
11
15
  ## Install & Setup
12
16
 
@@ -29,8 +33,8 @@ export default {
29
33
  };
30
34
  ```
31
35
 
32
- Create an ESLint configuration file (e.g., `eslint.config.js`) in your project and add the preset to the configuration
33
- array:
36
+ Create an ESLint configuration file (e.g., `eslint.config.js`) in your project and spread the preset into the
37
+ configuration array:
34
38
 
35
39
  ```javascript
36
40
  import { baseWithPrettierConfig } from '@enormora/eslint-config-base-with-prettier';
@@ -39,6 +43,81 @@ export default [
39
43
  {
40
44
  ignores: [ 'dist/**/*' ]
41
45
  },
42
- baseWithPrettierConfig
46
+ ...baseWithPrettierConfig
43
47
  ];
44
48
  ```
49
+
50
+ `baseWithPrettierConfig` is an array of flat config blocks. The first block targets the JS/TS/Vue file set and carries
51
+ the lint rules; the remaining blocks each scope `prettier/prettier` to one file family, with the markdown block
52
+ additionally enabling the semantic markdown linters.
53
+
54
+ | Block | Files | Rule(s) |
55
+ | :------------ | :----------------------------------------- | :------------------------------------------------------------------------------ |
56
+ | JavaScript/TS | `**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,vue}` | base lint rules + `prettier/prettier` |
57
+ | JSON | `**/*.json` | `prettier/prettier` |
58
+ | package.json | `**/package.json` | `package-json/*`, `json-schema-validator/no-invalid` |
59
+ | Markdown | `**/*.md` | `prettier/prettier`, `markdown/*`, `markdown-links/*`, `markdown-preferences/*` |
60
+ | YAML | `**/*.{yml,yaml}` | `prettier/prettier` |
61
+
62
+ ### Linting hidden directories
63
+
64
+ ESLint's CLI walker skips dot-directories such as `.github/` when you run `eslint .`. Because the formatter blocks
65
+ above match against file paths, they will silently _not_ run on files inside `.github/` unless you pass that path to
66
+ ESLint explicitly. The recommended lint script is therefore:
67
+
68
+ ```json
69
+ {
70
+ "scripts": {
71
+ "lint": "eslint . .github"
72
+ }
73
+ }
74
+ ```
75
+
76
+ ### Customizing or disabling the formatter on a file family
77
+
78
+ Because the blocks are plain flat config, override them the same way as any other ESLint config — add a later block
79
+ whose `files` glob overlaps the one you want to change. Later blocks win.
80
+
81
+ Disable prettier formatting for JSON entirely:
82
+
83
+ ```javascript
84
+ export default [
85
+ ...baseWithPrettierConfig,
86
+ { files: [ '**/*.json' ], rules: { 'prettier/prettier': 'off' } }
87
+ ];
88
+ ```
89
+
90
+ Ignore specific paths from formatting:
91
+
92
+ ```javascript
93
+ export default [
94
+ ...baseWithPrettierConfig,
95
+ { ignores: [ 'vendor/**/*.json', 'fixtures/**/*.md' ] }
96
+ ];
97
+ ```
98
+
99
+ ### Tweaking markdown lint rules
100
+
101
+ To override any markdown rule (from `@eslint/markdown`, `markdown-links`, or `markdown-preferences`), add a later
102
+ block — the same pattern as for any other ESLint rule:
103
+
104
+ ```javascript
105
+ export default [
106
+ ...baseWithPrettierConfig,
107
+ {
108
+ files: [ '**/*.md' ],
109
+ rules: {
110
+ 'markdown/no-html': 'off',
111
+ 'markdown/fenced-code-language': [ 'error', { required: [ 'js', 'ts' ] } ],
112
+ 'markdown-links/no-dead-urls': 'error',
113
+ 'markdown-preferences/heading-casing': [ 'error', { style: 'Sentence case' } ]
114
+ }
115
+ }
116
+ ];
117
+ ```
118
+
119
+ ## Limitations
120
+
121
+ - **No TOML coverage.** Prettier does not natively format `.toml` files. If you need TOML formatting, either use
122
+ [`@enormora/eslint-config-base`](../base/base.md) (which formats TOML via dprint) or wire your own prettier plugin
123
+ for TOML.
@@ -1,6 +1,7 @@
1
1
  import arrayFunctionPlugin from 'eslint-plugin-array-func';
2
2
  import noBarrelFiles from 'eslint-plugin-no-barrel-files';
3
3
  import promisePlugin from 'eslint-plugin-promise';
4
+ import * as regexpPlugin from 'eslint-plugin-regexp';
4
5
  import sonarjsPlugin from 'eslint-plugin-sonarjs';
5
6
  import unicornPlugin from 'eslint-plugin-unicorn';
6
7
 
@@ -13,16 +14,16 @@ function isSonarjsRuleDeprecated(sonarjsRule) {
13
14
  const nonDeprecatedSonarjsRuleNames = new Set(
14
15
  Object
15
16
  .entries(sonarjsPlugin.rules)
16
- .filter(([ , sonarjsRule ]) => {
17
+ .filter(function removeDeprecated([ , sonarjsRule ]) {
17
18
  return !isSonarjsRuleDeprecated(sonarjsRule);
18
19
  })
19
- .map(([ sonarjsRuleName ]) => {
20
+ .map(function toQualifiedRuleName([ sonarjsRuleName ]) {
20
21
  return `sonarjs/${sonarjsRuleName}`;
21
22
  })
22
23
  );
23
24
 
24
25
  const nonDeprecatedSonarjsRecommendedRules = Object.fromEntries(
25
- Object.entries(sonarjsPlugin.configs.recommended.rules).filter(([ sonarjsRuleName ]) => {
26
+ Object.entries(sonarjsPlugin.configs.recommended.rules).filter(function keepNonDeprecated([ sonarjsRuleName ]) {
26
27
  return nonDeprecatedSonarjsRuleNames.has(sonarjsRuleName);
27
28
  })
28
29
  );
@@ -33,7 +34,8 @@ export const bestPracticesRuleSet = {
33
34
  promise: promisePlugin,
34
35
  'array-func': arrayFunctionPlugin,
35
36
  sonarjs: sonarjsPlugin,
36
- 'no-barrel-files': noBarrelFiles
37
+ 'no-barrel-files': noBarrelFiles,
38
+ regexp: regexpPlugin
37
39
  },
38
40
  settings: {},
39
41
  rules: {
@@ -48,7 +50,7 @@ export const bestPracticesRuleSet = {
48
50
  'unicorn/no-null': 'off',
49
51
  'unicorn/catch-error-name': 'error',
50
52
  'unicorn/consistent-function-scoping': 'off',
51
- 'unicorn/custom-error-definition': 'off',
53
+ 'unicorn/custom-error-definition': 'error',
52
54
  'unicorn/error-message': 'error',
53
55
  'unicorn/escape-case': 'error',
54
56
  'unicorn/expiring-todo-comments': 'error',
@@ -67,7 +69,7 @@ export const bestPracticesRuleSet = {
67
69
  'unicorn/no-new-buffer': 'error',
68
70
  'unicorn/no-process-exit': 'error',
69
71
  'unicorn/no-unreadable-array-destructuring': 'error',
70
- 'unicorn/no-unused-properties': 'off',
72
+ 'unicorn/no-unused-properties': 'error',
71
73
  'unicorn/no-zero-fractions': 'error',
72
74
  'unicorn/number-literal-case': 'error',
73
75
  'unicorn/prefer-add-event-listener': 'error',
@@ -226,6 +228,9 @@ export const bestPracticesRuleSet = {
226
228
  'sonarjs/prefer-object-literal': 'error',
227
229
  'sonarjs/prefer-single-boolean-return': 'error',
228
230
  'sonarjs/prefer-while': 'error',
231
+ // regexp/no-super-linear-backtracking subsumes this with a sound NFA-based analysis
232
+ // (sonarjs is heuristic); see the regexp/* block below.
233
+ 'sonarjs/slow-regex': 'off',
229
234
 
230
235
  'promise/avoid-new': 'off',
231
236
  'promise/no-nesting': 'error',
@@ -250,6 +255,97 @@ export const bestPracticesRuleSet = {
250
255
  'promise/spec-only': 'error',
251
256
  'promise/prefer-catch': 'error',
252
257
 
253
- 'no-barrel-files/no-barrel-files': 'error'
258
+ 'no-barrel-files/no-barrel-files': 'error',
259
+
260
+ // eslint-plugin-regexp — purely additive on top of core / unicorn / sonarjs regex coverage.
261
+ // Rules with a working equivalent already in core, unicorn, or sonarjs are turned off here so
262
+ // each diagnostic is reported by exactly one rule. The only swap is regexp/no-super-linear-backtracking
263
+ // taking over from the (off-above) sonarjs/slow-regex.
264
+ 'regexp/confusing-quantifier': 'error',
265
+ 'regexp/control-character-escape': 'error',
266
+ 'regexp/match-any': 'error',
267
+ 'regexp/negation': 'error',
268
+ 'regexp/no-contradiction-with-assertion': 'error',
269
+ 'regexp/no-dupe-disjunctions': 'error',
270
+ 'regexp/no-empty-capturing-group': 'error',
271
+ 'regexp/no-empty-group': 'error',
272
+ 'regexp/no-empty-lookarounds-assertion': 'error',
273
+ 'regexp/no-empty-string-literal': 'error',
274
+ 'regexp/no-escape-backspace': 'error',
275
+ 'regexp/no-extra-lookaround-assertions': 'error',
276
+ 'regexp/no-invisible-character': 'error',
277
+ 'regexp/no-lazy-ends': 'error',
278
+ 'regexp/no-legacy-features': 'error',
279
+ 'regexp/no-misleading-capturing-group': 'error',
280
+ 'regexp/no-missing-g-flag': 'error',
281
+ 'regexp/no-non-standard-flag': 'error',
282
+ 'regexp/no-obscure-range': 'error',
283
+ 'regexp/no-octal': 'error',
284
+ 'regexp/no-optional-assertion': 'error',
285
+ 'regexp/no-potentially-useless-backreference': 'error',
286
+ 'regexp/no-standalone-backslash': 'error',
287
+ 'regexp/no-super-linear-backtracking': 'error',
288
+ 'regexp/no-super-linear-move': 'error',
289
+ 'regexp/no-trivially-nested-assertion': 'error',
290
+ 'regexp/no-trivially-nested-quantifier': 'error',
291
+ 'regexp/no-unused-capturing-group': 'error',
292
+ 'regexp/no-useless-assertions': 'error',
293
+ 'regexp/no-useless-character-class': 'error',
294
+ 'regexp/no-useless-dollar-replacements': 'error',
295
+ 'regexp/no-useless-flag': 'error',
296
+ 'regexp/no-useless-lazy': 'error',
297
+ 'regexp/no-useless-non-capturing-group': 'error',
298
+ 'regexp/no-useless-quantifier': 'error',
299
+ 'regexp/no-useless-range': 'error',
300
+ 'regexp/no-useless-set-operand': 'error',
301
+ 'regexp/no-useless-string-literal': 'error',
302
+ 'regexp/no-useless-two-nums-quantifier': 'error',
303
+ 'regexp/no-zero-quantifier': 'error',
304
+ 'regexp/optimal-lookaround-quantifier': 'error',
305
+ 'regexp/optimal-quantifier-concatenation': 'error',
306
+ 'regexp/prefer-escape-replacement-dollar-char': 'error',
307
+ 'regexp/prefer-named-backreference': 'error',
308
+ 'regexp/prefer-named-replacement': 'error',
309
+ 'regexp/prefer-result-array-groups': 'error',
310
+ 'regexp/prefer-set-operation': 'error',
311
+ 'regexp/prefer-unicode-codepoint-escapes': 'error',
312
+ 'regexp/simplify-set-operations': 'error',
313
+
314
+ // Overlap with existing rules — keep the existing rule as single source of truth.
315
+ 'regexp/no-control-character': 'off', // core no-control-regex
316
+ 'regexp/no-dupe-characters-character-class': 'off', // sonarjs/duplicates-in-character-class
317
+ 'regexp/no-empty-alternative': 'off', // sonarjs/no-empty-alternatives
318
+ 'regexp/no-empty-character-class': 'off', // core no-empty-character-class
319
+ 'regexp/no-invalid-regexp': 'off', // core no-invalid-regexp
320
+ 'regexp/no-misleading-unicode-character': 'off', // core no-misleading-character-class
321
+ 'regexp/no-useless-backreference': 'off', // core no-useless-backreference
322
+ 'regexp/no-useless-escape': 'off', // core no-useless-escape
323
+ 'regexp/prefer-character-class': 'off', // unicorn/better-regex + sonarjs/concise-regex
324
+ 'regexp/prefer-d': 'off', // unicorn/better-regex
325
+ 'regexp/prefer-named-capture-group': 'off', // core prefer-named-capture-group
326
+ 'regexp/prefer-plus-quantifier': 'off', // unicorn/better-regex
327
+ 'regexp/prefer-question-quantifier': 'off', // unicorn/better-regex
328
+ 'regexp/prefer-regexp-exec': 'off', // @typescript-eslint/prefer-regexp-exec
329
+ 'regexp/prefer-regexp-test': 'off', // unicorn/prefer-regexp-test
330
+ 'regexp/prefer-star-quantifier': 'off', // unicorn/better-regex
331
+ 'regexp/prefer-w': 'off', // unicorn/better-regex
332
+ 'regexp/require-unicode-regexp': 'off', // matches core require-unicode-regexp (off)
333
+ 'regexp/strict': 'off', // unicorn/better-regex
334
+
335
+ // Pure style preferences outside the project's scope.
336
+ 'regexp/grapheme-string-literal': 'off',
337
+ 'regexp/hexadecimal-escape': 'off',
338
+ 'regexp/letter-case': 'off',
339
+ 'regexp/prefer-lookaround': 'off',
340
+ 'regexp/prefer-predefined-assertion': 'off',
341
+ 'regexp/prefer-quantifier': 'off',
342
+ 'regexp/prefer-range': 'off',
343
+ 'regexp/require-unicode-sets-regexp': 'off',
344
+ 'regexp/sort-alternatives': 'off',
345
+ 'regexp/sort-character-class-elements': 'off',
346
+ 'regexp/sort-flags': 'off',
347
+ 'regexp/unicode-escape': 'off',
348
+ 'regexp/unicode-property': 'off',
349
+ 'regexp/use-ignore-case': 'off'
254
350
  }
255
351
  };
@@ -5,7 +5,7 @@ const noRestrictedSyntaxRule = builtinRules.get('no-restricted-syntax');
5
5
  export function createRestrictedSyntaxPlugin(ruleNames) {
6
6
  return {
7
7
  rules: Object.fromEntries(
8
- ruleNames.map((ruleName) => {
8
+ ruleNames.map(function toRuleEntry(ruleName) {
9
9
  return [ ruleName, noRestrictedSyntaxRule ];
10
10
  })
11
11
  )
@@ -33,7 +33,7 @@ export const noSwitchStatementRestriction = {
33
33
  };
34
34
 
35
35
  const emptyFunctionBodySelector = [ 'FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression' ]
36
- .map((kind) => {
36
+ .map(function toEmptyBodySelector(kind) {
37
37
  return `${kind} > BlockStatement[body.length=0]`;
38
38
  })
39
39
  .join(', ');
@@ -47,3 +47,16 @@ export const noInOperatorRestriction = {
47
47
  selector: 'BinaryExpression[operator="in"]',
48
48
  message: 'The `in` operator is not allowed. Use `Object.hasOwn` instead.'
49
49
  };
50
+
51
+ const lexicalBindingReferences = [
52
+ 'ThisExpression',
53
+ 'Super',
54
+ 'MetaProperty[meta.name="new"]',
55
+ 'Identifier[name="arguments"]'
56
+ ]
57
+ .join(', ');
58
+
59
+ export const noUnnecessaryArrowFunctionRestriction = {
60
+ selector: `ArrowFunctionExpression:not(:has(${lexicalBindingReferences}))`,
61
+ message: 'Arrow functions are only allowed when they use lexical `this`, `super`, `new.target`, or `arguments`.'
62
+ };
package/sbom.cdx.json CHANGED
@@ -16,12 +16,25 @@
16
16
  "component": {
17
17
  "type": "library",
18
18
  "name": "@enormora/eslint-config-base-with-prettier",
19
- "version": "0.0.3",
20
- "bom-ref": "pkg:npm/@enormora/eslint-config-base-with-prettier@0.0.3",
21
- "purl": "pkg:npm/@enormora/eslint-config-base-with-prettier@0.0.3"
19
+ "version": "0.0.5",
20
+ "bom-ref": "pkg:npm/@enormora/eslint-config-base-with-prettier@0.0.5",
21
+ "purl": "pkg:npm/@enormora/eslint-config-base-with-prettier@0.0.5"
22
22
  }
23
23
  },
24
24
  "components": [
25
+ {
26
+ "type": "library",
27
+ "name": "@ben_12/eslint-simple-parser",
28
+ "version": "0.1.0",
29
+ "bom-ref": "pkg:npm/@ben_12/eslint-simple-parser@0.1.0",
30
+ "scope": "required",
31
+ "licenses": [
32
+ {
33
+ "expression": "MIT"
34
+ }
35
+ ],
36
+ "purl": "pkg:npm/@ben_12/eslint-simple-parser@0.1.0"
37
+ },
25
38
  {
26
39
  "type": "library",
27
40
  "name": "@cspell/eslint-plugin",
@@ -48,6 +61,19 @@
48
61
  ],
49
62
  "purl": "pkg:npm/@eslint-community/eslint-plugin-eslint-comments@4.7.2"
50
63
  },
64
+ {
65
+ "type": "library",
66
+ "name": "@eslint/markdown",
67
+ "version": "8.0.2",
68
+ "bom-ref": "pkg:npm/@eslint/markdown@8.0.2",
69
+ "scope": "required",
70
+ "licenses": [
71
+ {
72
+ "expression": "MIT"
73
+ }
74
+ ],
75
+ "purl": "pkg:npm/@eslint/markdown@8.0.2"
76
+ },
51
77
  {
52
78
  "type": "library",
53
79
  "name": "@stylistic/eslint-plugin",
@@ -100,6 +126,45 @@
100
126
  ],
101
127
  "purl": "pkg:npm/eslint-plugin-import-x@4.16.2"
102
128
  },
129
+ {
130
+ "type": "library",
131
+ "name": "eslint-plugin-json-schema-validator",
132
+ "version": "6.2.0",
133
+ "bom-ref": "pkg:npm/eslint-plugin-json-schema-validator@6.2.0",
134
+ "scope": "required",
135
+ "licenses": [
136
+ {
137
+ "expression": "MIT"
138
+ }
139
+ ],
140
+ "purl": "pkg:npm/eslint-plugin-json-schema-validator@6.2.0"
141
+ },
142
+ {
143
+ "type": "library",
144
+ "name": "eslint-plugin-markdown-links",
145
+ "version": "0.9.0",
146
+ "bom-ref": "pkg:npm/eslint-plugin-markdown-links@0.9.0",
147
+ "scope": "required",
148
+ "licenses": [
149
+ {
150
+ "expression": "MIT"
151
+ }
152
+ ],
153
+ "purl": "pkg:npm/eslint-plugin-markdown-links@0.9.0"
154
+ },
155
+ {
156
+ "type": "library",
157
+ "name": "eslint-plugin-markdown-preferences",
158
+ "version": "0.41.1",
159
+ "bom-ref": "pkg:npm/eslint-plugin-markdown-preferences@0.41.1",
160
+ "scope": "required",
161
+ "licenses": [
162
+ {
163
+ "expression": "MIT"
164
+ }
165
+ ],
166
+ "purl": "pkg:npm/eslint-plugin-markdown-preferences@0.41.1"
167
+ },
103
168
  {
104
169
  "type": "library",
105
170
  "name": "eslint-plugin-no-barrel-files",
@@ -126,6 +191,19 @@
126
191
  ],
127
192
  "purl": "pkg:npm/eslint-plugin-no-secrets@2.3.3"
128
193
  },
194
+ {
195
+ "type": "library",
196
+ "name": "eslint-plugin-package-json",
197
+ "version": "1.3.0",
198
+ "bom-ref": "pkg:npm/eslint-plugin-package-json@1.3.0",
199
+ "scope": "required",
200
+ "licenses": [
201
+ {
202
+ "expression": "MIT"
203
+ }
204
+ ],
205
+ "purl": "pkg:npm/eslint-plugin-package-json@1.3.0"
206
+ },
129
207
  {
130
208
  "type": "library",
131
209
  "name": "eslint-plugin-prettier",
@@ -152,6 +230,19 @@
152
230
  ],
153
231
  "purl": "pkg:npm/eslint-plugin-promise@7.3.0"
154
232
  },
233
+ {
234
+ "type": "library",
235
+ "name": "eslint-plugin-regexp",
236
+ "version": "3.1.0",
237
+ "bom-ref": "pkg:npm/eslint-plugin-regexp@3.1.0",
238
+ "scope": "required",
239
+ "licenses": [
240
+ {
241
+ "expression": "MIT"
242
+ }
243
+ ],
244
+ "purl": "pkg:npm/eslint-plugin-regexp@3.1.0"
245
+ },
155
246
  {
156
247
  "type": "library",
157
248
  "name": "eslint-plugin-sonarjs",
@@ -190,33 +281,60 @@
190
281
  }
191
282
  ],
192
283
  "purl": "pkg:npm/eslint@%5E10.0.0"
284
+ },
285
+ {
286
+ "type": "library",
287
+ "name": "jsonc-eslint-parser",
288
+ "version": "3.1.0",
289
+ "bom-ref": "pkg:npm/jsonc-eslint-parser@3.1.0",
290
+ "scope": "required",
291
+ "licenses": [
292
+ {
293
+ "expression": "MIT"
294
+ }
295
+ ],
296
+ "purl": "pkg:npm/jsonc-eslint-parser@3.1.0"
193
297
  }
194
298
  ],
195
299
  "dependencies": [
300
+ {
301
+ "ref": "pkg:npm/@ben_12/eslint-simple-parser@0.1.0"
302
+ },
196
303
  {
197
304
  "ref": "pkg:npm/@cspell/eslint-plugin@10.0.1"
198
305
  },
199
306
  {
200
- "ref": "pkg:npm/@enormora/eslint-config-base-with-prettier@0.0.3",
307
+ "ref": "pkg:npm/@enormora/eslint-config-base-with-prettier@0.0.5",
201
308
  "dependsOn": [
309
+ "pkg:npm/@ben_12/eslint-simple-parser@0.1.0",
202
310
  "pkg:npm/@cspell/eslint-plugin@10.0.1",
203
311
  "pkg:npm/@eslint-community/eslint-plugin-eslint-comments@4.7.2",
312
+ "pkg:npm/@eslint/markdown@8.0.2",
204
313
  "pkg:npm/@stylistic/eslint-plugin@5.10.0",
205
314
  "pkg:npm/eslint-plugin-array-func@5.1.1",
206
315
  "pkg:npm/eslint-plugin-destructuring@2.2.1",
207
316
  "pkg:npm/eslint-plugin-import-x@4.16.2",
317
+ "pkg:npm/eslint-plugin-json-schema-validator@6.2.0",
318
+ "pkg:npm/eslint-plugin-markdown-links@0.9.0",
319
+ "pkg:npm/eslint-plugin-markdown-preferences@0.41.1",
208
320
  "pkg:npm/eslint-plugin-no-barrel-files@1.3.1",
209
321
  "pkg:npm/eslint-plugin-no-secrets@2.3.3",
322
+ "pkg:npm/eslint-plugin-package-json@1.3.0",
210
323
  "pkg:npm/eslint-plugin-prettier@5.5.6",
211
324
  "pkg:npm/eslint-plugin-promise@7.3.0",
325
+ "pkg:npm/eslint-plugin-regexp@3.1.0",
212
326
  "pkg:npm/eslint-plugin-sonarjs@4.0.3",
213
327
  "pkg:npm/eslint-plugin-unicorn@64.0.0",
214
- "pkg:npm/eslint@%5E10.0.0"
328
+ "pkg:npm/eslint@%5E10.0.0",
329
+ "pkg:npm/jsonc-eslint-parser@3.1.0"
215
330
  ]
216
331
  },
217
332
  {
218
333
  "ref": "pkg:npm/@eslint-community/eslint-plugin-eslint-comments@4.7.2"
219
334
  },
335
+ {
336
+ "ref": "pkg:npm/@eslint/markdown@8.0.2"
337
+ },
220
338
  {
221
339
  "ref": "pkg:npm/@stylistic/eslint-plugin@5.10.0"
222
340
  },
@@ -229,18 +347,33 @@
229
347
  {
230
348
  "ref": "pkg:npm/eslint-plugin-import-x@4.16.2"
231
349
  },
350
+ {
351
+ "ref": "pkg:npm/eslint-plugin-json-schema-validator@6.2.0"
352
+ },
353
+ {
354
+ "ref": "pkg:npm/eslint-plugin-markdown-links@0.9.0"
355
+ },
356
+ {
357
+ "ref": "pkg:npm/eslint-plugin-markdown-preferences@0.41.1"
358
+ },
232
359
  {
233
360
  "ref": "pkg:npm/eslint-plugin-no-barrel-files@1.3.1"
234
361
  },
235
362
  {
236
363
  "ref": "pkg:npm/eslint-plugin-no-secrets@2.3.3"
237
364
  },
365
+ {
366
+ "ref": "pkg:npm/eslint-plugin-package-json@1.3.0"
367
+ },
238
368
  {
239
369
  "ref": "pkg:npm/eslint-plugin-prettier@5.5.6"
240
370
  },
241
371
  {
242
372
  "ref": "pkg:npm/eslint-plugin-promise@7.3.0"
243
373
  },
374
+ {
375
+ "ref": "pkg:npm/eslint-plugin-regexp@3.1.0"
376
+ },
244
377
  {
245
378
  "ref": "pkg:npm/eslint-plugin-sonarjs@4.0.3"
246
379
  },
@@ -249,6 +382,9 @@
249
382
  },
250
383
  {
251
384
  "ref": "pkg:npm/eslint@%5E10.0.0"
385
+ },
386
+ {
387
+ "ref": "pkg:npm/jsonc-eslint-parser@3.1.0"
252
388
  }
253
389
  ]
254
390
  }