@forthtilliath/eslint-config 0.4.2 → 0.5.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 +30 -0
- package/dist/angular.d.ts.map +1 -1
- package/dist/angular.js +21 -1
- package/dist/base.d.ts +8 -0
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +16 -7
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -31,6 +31,17 @@ there's nothing else to install per variant.
|
|
|
31
31
|
|
|
32
32
|
## Usage
|
|
33
33
|
|
|
34
|
+
Quick reference — pick the row matching the package, in its `eslint.config.ts`:
|
|
35
|
+
|
|
36
|
+
| Variant | Subpath | Use for | Extends |
|
|
37
|
+
| ------------------- | --------------- | -------------------------- | ------------- |
|
|
38
|
+
| `baseConfig` | `.` (root) | A plain TypeScript library | — |
|
|
39
|
+
| `reactConfig` | `/react` | A React library | `baseConfig` |
|
|
40
|
+
| `nextJsConfig` | `/nextjs` | A Next.js app | `reactConfig` |
|
|
41
|
+
| `storybookConfig` | `/storybook` | A Storybook app | `reactConfig` |
|
|
42
|
+
| `reactNativeConfig` | `/react-native` | A React Native / Expo app | `reactConfig` |
|
|
43
|
+
| `angularConfig` | `/angular` | An Angular app/library | `baseConfig` |
|
|
44
|
+
|
|
34
45
|
Pick the variant that matches the package, in its `eslint.config.ts`:
|
|
35
46
|
|
|
36
47
|
```ts
|
|
@@ -144,6 +155,23 @@ Rules that need type information (`consistent-type-exports`,
|
|
|
144
155
|
from linting entirely — none of them belong to a package's own `tsconfig`
|
|
145
156
|
project, so type-aware rules crash on them otherwise.
|
|
146
157
|
|
|
158
|
+
### Angular import order
|
|
159
|
+
|
|
160
|
+
`angularConfig` overrides `simple-import-sort/imports` on `**/*.ts` so
|
|
161
|
+
`@angular/core`/`rxjs` sort before every other package, ahead of the generic
|
|
162
|
+
"third-party packages, alphabetically" group `baseConfig` uses everywhere
|
|
163
|
+
else — the conventional Angular reading order (framework, then everything
|
|
164
|
+
else, then app code).
|
|
165
|
+
|
|
166
|
+
## Testing this package
|
|
167
|
+
|
|
168
|
+
Unlike the other five variants — each already exercised by whatever
|
|
169
|
+
package/app in this monorepo lints under them — `angularConfig` has no real
|
|
170
|
+
consumer here yet, so `src/angular.test.js` lints small fixture files under
|
|
171
|
+
`src/__fixtures__/angular/` through ESLint's Node API directly, standing in
|
|
172
|
+
for that. Extend it (or add a sibling `<variant>.test.js`) whenever a variant
|
|
173
|
+
changes without a real consumer to catch a regression.
|
|
174
|
+
|
|
147
175
|
## Scripts
|
|
148
176
|
|
|
149
177
|
```bash
|
|
@@ -151,6 +179,8 @@ pnpm run build # tsc -> dist/ (consumers import the built output)
|
|
|
151
179
|
pnpm run dev # tsc --watch
|
|
152
180
|
pnpm run check-types # tsc --noEmit
|
|
153
181
|
pnpm run lint # eslint (lints its own src/)
|
|
182
|
+
pnpm run test # vitest run
|
|
183
|
+
pnpm run test:watch # vitest
|
|
154
184
|
```
|
|
155
185
|
|
|
156
186
|
Run `pnpm run build` after editing `src/*.js` — consuming packages resolve
|
package/dist/angular.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular.d.ts","sourceRoot":"","sources":["../src/angular.js"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,8CAHW,OAAO,WAAW,EAAE,iBAAiB,GACnC,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"angular.d.ts","sourceRoot":"","sources":["../src/angular.js"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,8CAHW,OAAO,WAAW,EAAE,iBAAiB,GACnC,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CA+D5C;AAED;;;;8CAI8C;AAC9C,4BADU,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CACS"}
|
package/dist/angular.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import angular from "angular-eslint";
|
|
2
2
|
import { defineConfig } from "eslint/config";
|
|
3
3
|
import tseslint from "typescript-eslint";
|
|
4
|
-
import { createBaseConfig } from "./base.js";
|
|
4
|
+
import { createBaseConfig, NODE_BUILTIN_IMPORT_GROUP } from "./base.js";
|
|
5
5
|
/**
|
|
6
6
|
* A custom ESLint configuration for Angular applications/libraries.
|
|
7
7
|
*
|
|
@@ -38,6 +38,26 @@ export function createAngularConfig(options) {
|
|
|
38
38
|
// Un composant/page Angular sans logique propre (juste un template +
|
|
39
39
|
// decorateur) est un corps de classe legitimement vide, pas du code mort.
|
|
40
40
|
"@typescript-eslint/no-extraneous-class": "off",
|
|
41
|
+
// Convention Angular : le framework (et RxJS, quasi-systematiquement
|
|
42
|
+
// utilise a ses cotes) se lit avant le reste — packages tiers, puis
|
|
43
|
+
// imports internes de l'app. baseConfig's generic "^@?\\w" group
|
|
44
|
+
// sorts every third-party package alphabetically together, which
|
|
45
|
+
// would interleave "@angular/core" with unrelated libs instead.
|
|
46
|
+
"simple-import-sort/imports": [
|
|
47
|
+
"error",
|
|
48
|
+
{
|
|
49
|
+
groups: [
|
|
50
|
+
NODE_BUILTIN_IMPORT_GROUP,
|
|
51
|
+
["^@angular", "^rxjs"],
|
|
52
|
+
["^@?\\w"],
|
|
53
|
+
["^(@forthtilliath)(/.*|$)"],
|
|
54
|
+
["^(@|@ui|components|utils|config)(/.*|$)"],
|
|
55
|
+
["^\\u0000"],
|
|
56
|
+
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
57
|
+
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
41
61
|
},
|
|
42
62
|
},
|
|
43
63
|
{
|
package/dist/base.d.ts
CHANGED
|
@@ -19,6 +19,14 @@
|
|
|
19
19
|
* @returns {import("eslint").Linter.Config[]}
|
|
20
20
|
*/
|
|
21
21
|
export function createBaseConfig({ prettier, strict, turbo, }?: BaseConfigOptions): import("eslint").Linter.Config[];
|
|
22
|
+
/**
|
|
23
|
+
* Node.js builtins without the `node:` prefix, as the first
|
|
24
|
+
* `simple-import-sort/imports` group. Exported so other variants (e.g.
|
|
25
|
+
* angular.js, which overrides this rule with Angular-specific groups) don't
|
|
26
|
+
* have to duplicate the list to keep builtins sorted first too.
|
|
27
|
+
* @type {string[]}
|
|
28
|
+
*/
|
|
29
|
+
export const NODE_BUILTIN_IMPORT_GROUP: string[];
|
|
22
30
|
/**
|
|
23
31
|
* A shared ESLint configuration for the repository, with the default options.
|
|
24
32
|
* Use `createBaseConfig(options)` instead to customize it.
|
package/dist/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.js"],"names":[],"mappings":"AAuBA;;;;;;;;;;;;;GAaG;AAEH;;;;;GAKG;AACH,gEAHW,iBAAiB,GACf,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAoI5C;AAtKD;;;;;;GAMG;AACH,wCAFU,MAAM,EAAE,CAQhB;AA2JF;;;;;KAKK;AACL,yBAFU,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAEG"}
|
package/dist/base.js
CHANGED
|
@@ -5,6 +5,20 @@ import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
|
5
5
|
import turboPlugin from "eslint-plugin-turbo";
|
|
6
6
|
import globals from "globals";
|
|
7
7
|
import tseslint from "typescript-eslint";
|
|
8
|
+
/**
|
|
9
|
+
* Node.js builtins without the `node:` prefix, as the first
|
|
10
|
+
* `simple-import-sort/imports` group. Exported so other variants (e.g.
|
|
11
|
+
* angular.js, which overrides this rule with Angular-specific groups) don't
|
|
12
|
+
* have to duplicate the list to keep builtins sorted first too.
|
|
13
|
+
* @type {string[]}
|
|
14
|
+
*/
|
|
15
|
+
export const NODE_BUILTIN_IMPORT_GROUP = [
|
|
16
|
+
// Node.js builtins. You could also generate this regex if you use a `.js` config.
|
|
17
|
+
// For example: `^(${require("module").builtinModules.join("|")})(/|$)`
|
|
18
|
+
// Note that if you use the `node:` prefix for Node.js builtins,
|
|
19
|
+
// you can avoid this complexity: You can simply use "^node:".
|
|
20
|
+
"^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)",
|
|
21
|
+
];
|
|
8
22
|
/**
|
|
9
23
|
* @typedef {object} BaseConfigOptions
|
|
10
24
|
* @property {boolean} [prettier=true] - Append eslint-config-prettier at the
|
|
@@ -33,6 +47,7 @@ export function createBaseConfig({ prettier = true, strict = true, turbo = true,
|
|
|
33
47
|
{
|
|
34
48
|
ignores: [
|
|
35
49
|
"dist/**",
|
|
50
|
+
"coverage/**",
|
|
36
51
|
"storybook-static/**",
|
|
37
52
|
"postcss.config.cjs",
|
|
38
53
|
"postcss.config.mjs",
|
|
@@ -72,13 +87,7 @@ export function createBaseConfig({ prettier = true, strict = true, turbo = true,
|
|
|
72
87
|
"error",
|
|
73
88
|
{
|
|
74
89
|
groups: [
|
|
75
|
-
|
|
76
|
-
// For example: `^(${require("module").builtinModules.join("|")})(/|$)`
|
|
77
|
-
// Note that if you use the `node:` prefix for Node.js builtins,
|
|
78
|
-
// you can avoid this complexity: You can simply use "^node:".
|
|
79
|
-
[
|
|
80
|
-
"^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)",
|
|
81
|
-
],
|
|
90
|
+
NODE_BUILTIN_IMPORT_GROUP,
|
|
82
91
|
// Packages. `react` related packages come first.
|
|
83
92
|
["^react", "^@?\\w"],
|
|
84
93
|
// Internal packages.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forthtilliath/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -45,15 +45,20 @@
|
|
|
45
45
|
"typescript": ">=5.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
+
"@angular/core": "^21.0.0",
|
|
48
49
|
"eslint": "10.7.0",
|
|
50
|
+
"rxjs": "^7.8.0",
|
|
49
51
|
"typescript": "^5.9.3",
|
|
52
|
+
"vitest": "^4.1.10",
|
|
50
53
|
"@forthtilliath/typescript-config": "0.0.0"
|
|
51
54
|
},
|
|
52
55
|
"scripts": {
|
|
53
|
-
"dev": "tsc --watch",
|
|
54
|
-
"build": "tsc",
|
|
56
|
+
"dev": "tsc --watch -p tsconfig.build.json",
|
|
57
|
+
"build": "tsc -p tsconfig.build.json",
|
|
55
58
|
"clean": "rm -rf dist",
|
|
56
59
|
"check-types": "tsc --noEmit",
|
|
57
|
-
"lint": "eslint . --max-warnings 0"
|
|
60
|
+
"lint": "eslint . --max-warnings 0",
|
|
61
|
+
"test": "vitest run",
|
|
62
|
+
"test:watch": "vitest"
|
|
58
63
|
}
|
|
59
64
|
}
|