@the-stranger/eslint-plugin 2.0.0 → 2.0.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.
package/README.md CHANGED
@@ -1,29 +1,108 @@
1
1
  # @the-stranger/eslint-plugin
2
2
 
3
- ESLint plugin, which mostly consists of common configurations. It also includes a couple of ESLint configuration utilities.
3
+ ESLint plugin that provides shared rule presets plus utilities for authoring ESLint config.
4
4
 
5
- ## Configurations Provided
5
+ ## Installation
6
6
 
7
- The configurations provided by this plugin include:
7
+ Requires Node.js 24+ and ESLint 9+.
8
8
 
9
- - **JSDoc**: Recommended configs from [eslint-plugin-jsdoc] for both TypeScript and JavaScript files, and allows the `@document` tag used by Docusaurus.
10
- - **Node (n)**: Extends recommended config from [eslint-plugin-n].
11
- - **Perfectionist**: Extends [eslint-plugin-perfectionist]; sorts ALL THE THINGS!
9
+ ```bash
10
+ npm install --save-dev @the-stranger/eslint-plugin
11
+ ```
12
+
13
+ ## Optional peer dependencies
14
+
15
+ Install only the peers you need for the conditional presets:
16
+
17
+ - `eslint-plugin-jest@^29.12.1`
18
+ - `@vitest/eslint-plugin@^1.6.6`
19
+ - `eslint-plugin-toml@^0.12.0` and `toml-eslint-parser@^0.10.1`
20
+ - `@nx/eslint-plugin@21`
21
+
22
+ ## Usage
23
+
24
+ In your `eslint.config.js`, extend the presets you want:
25
+
26
+ ```javascript
27
+ import le from '@the-stranger/eslint-plugin'
28
+ import leJest from '@the-stranger/eslint-plugin/configs/jest'
29
+ import leVitest from '@the-stranger/eslint-plugin/configs/vitest'
30
+ import leToml from '@the-stranger/eslint-plugin/configs/toml'
31
+ import leNx from '@the-stranger/eslint-plugin/configs/nx'
32
+ import { objectNamer, setRuleLevel } from '@the-stranger/eslint-plugin/utils'
33
+ import { defineConfig } from 'eslint/config'
34
+
35
+ export default defineConfig({
36
+ extends: [
37
+ // all-in-one
38
+ le.configs.recommended,
39
+
40
+ // or pick and choose
41
+ le.configs.jsdoc,
42
+ le.configs.jsonc,
43
+ le.configs.n,
44
+ le.configs.perfectionist,
45
+ le.configs.promise,
46
+ le.configs.regexp,
47
+ le.configs.ts,
48
+ le.configs.unicorn,
49
+ le.configs.yml,
50
+
51
+ // conditional presets when peers are installed
52
+ leJest,
53
+ leVitest,
54
+ leToml,
55
+ leNx,
56
+
57
+ // customization helpers
58
+ setRuleLevel('error', le.configs.perfectionist),
59
+ objectNamer(le.configs.ts, 'my-eslint-config'),
60
+ ],
61
+ })
62
+ ```
63
+
64
+ ## Configurations
65
+
66
+ - **JSDoc**: Recommended config from [eslint-plugin-jsdoc] for both TypeScript and JavaScript files; allows the `@document` tag used by Docusaurus.
67
+ - **JSONC**: Enables key and array sorting in JSON/JSONC documents using [eslint-plugin-jsonc].
68
+ - **Node (n)**: Extends the recommended config from [eslint-plugin-n].
69
+ - **Perfectionist**: Extends [eslint-plugin-perfectionist]; sorts all the things.
12
70
  - **Promise**: Recommended rules from [eslint-plugin-promise].
13
71
  - **Regexp**: Recommended rules from [eslint-plugin-regexp].
14
- - **TypeScript ESLint**: Sets up linting for TypeScript using either [@nx/eslint-plugin] or [typescript-eslint], disabling some of the noisier ones
15
- - **Unicorn**: Recommended rules from [eslint-plugin-unicorn] with a bunch of customizations.
16
- - **YAML**: Recommended config from [eslint-plugin-yml], and adds key and array sorting. Uses [yaml-eslint-parser].
72
+ - **TypeScript (ts)**: Sets up TypeScript linting via [typescript-eslint], disabling a few noisy rules; falls back when Nx is unavailable.
73
+ - **Unicorn**: Recommended rules from [eslint-plugin-unicorn] with customizations.
74
+ - **YAML**: Recommended config from [eslint-plugin-yml], plus key and array sorting via [yaml-eslint-parser].
75
+
76
+ ### Conditional configurations
77
+
78
+ These presets load only when their peer dependencies are present:
79
+
80
+ - **Jest**: Uses [eslint-plugin-jest]; aligned with the Vitest rules for consistency.
81
+ - **Vitest**: Uses [@vitest/eslint-plugin] to keep test files readable.
82
+ - **TOML**: Uses [eslint-plugin-toml] and [toml-eslint-parser] to lint TOML files.
83
+ - **Nx**: Extends Nx's recommended monorepo config from [@nx/eslint-plugin].
84
+
85
+ ## Utilities
86
+
87
+ - **getFilePatterns**: Generates glob patterns.
88
+ - **namer**: Simple helper for naming config blocks.
89
+ - **objectNamer**: Wraps a config object and assigns it a friendly name for reports.
90
+ - **setRuleLevel**: Sets the severity of some or all rules in a config, handling nested configs.
17
91
 
18
92
  <!-- Links -->
19
93
 
20
94
  [@nx/eslint-plugin]: https://nx.dev/docs/technologies/eslint/eslint-plugin/introduction
95
+ [@vitest/eslint-plugin]: https://github.com/vitest-dev/eslint-plugin-vitest
96
+ [eslint-plugin-jest]: https://github.com/jest-community/eslint-plugin-jest
21
97
  [eslint-plugin-jsdoc]: https://github.com/gajus/eslint-plugin-jsdoc
98
+ [eslint-plugin-jsonc]: https://ota-meshi.github.io/eslint-plugin-jsonc
22
99
  [eslint-plugin-n]: https://github.com/eslint-community/eslint-plugin-n
23
100
  [eslint-plugin-perfectionist]: https://perfectionist.dev
24
101
  [eslint-plugin-promise]: https://github.com/eslint-community/eslint-plugin-promise
25
102
  [eslint-plugin-regexp]: https://ota-meshi.github.io/eslint-plugin-regexp
103
+ [eslint-plugin-toml]: https://ota-meshi.github.io/eslint-plugin-toml
26
104
  [eslint-plugin-unicorn]: https://github.com/sindresorhus/eslint-plugin-unicorn
27
105
  [eslint-plugin-yml]: https://ota-meshi.github.io/eslint-plugin-yml
106
+ [toml-eslint-parser]: https://ota-meshi.github.io/toml-eslint-parser
28
107
  [typescript-eslint]: https://typescript-eslint.io
29
108
  [yaml-eslint-parser]: https://github.com/ota-meshi/yaml-eslint-parser
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-stranger/eslint-plugin",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "repository": {
5
5
  "url": "https://github.com/the-chris-strange/the-stranger",
6
6
  "directory": "packages/eslint-plugin"
@@ -70,7 +70,7 @@
70
70
  "vitest": "^3.2.4"
71
71
  },
72
72
  "peerDependencies": {
73
- "@nx/eslint-plugin": "21.6.4",
73
+ "@nx/eslint-plugin": "^21",
74
74
  "@vitest/eslint-plugin": "^1.6.6",
75
75
  "eslint": "^9",
76
76
  "eslint-plugin-jest": "^29.12.1",
@@ -6,7 +6,7 @@ const config = [
6
6
  files: getFilePatterns(FilePatterns.source),
7
7
  name: namer('unnecessary ts rules'),
8
8
  rules: {
9
- // I do what I want ¯\_(ツ)_/¯
9
+ /** I do what I want ¯\\\_(ツ)\_/¯ */
10
10
  '@typescript-eslint/no-explicit-any': 'off',
11
11
  '@typescript-eslint/no-unused-vars': 'warn',
12
12
  },
package/src/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { namer, type Named } from './lib/namer.js';
1
+ export { namer, objectNamer, type Named } from './lib/namer.js';
2
2
  export { FilePatterns, getFilePatterns } from './lib/patterns.js';
3
3
  export { setRuleLevel } from './lib/severity.js';
4
4
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../packages/eslint-plugin/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../packages/eslint-plugin/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA"}
package/src/utils.js CHANGED
@@ -1,3 +1,3 @@
1
- export { namer } from './lib/namer.js';
1
+ export { namer, objectNamer } from './lib/namer.js';
2
2
  export { FilePatterns, getFilePatterns } from './lib/patterns.js';
3
3
  export { setRuleLevel } from './lib/severity.js';