eslint-config-nick2bad4u 1.2.8 → 1.2.9
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 +49 -23
- package/dist/preset.js +17 -1
- package/dist/preset.js.map +1 -1
- package/dist/shared-config.js +183 -312
- package/dist/shared-config.js.map +1 -1
- package/docs/configuration.md +56 -22
- package/docs/migration.md +47 -23
- package/eslint.config.mjs +5 -1
- package/examples/eslint.config.create.mjs +2 -3
- package/index.d.ts +28 -8
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -85,31 +85,29 @@ Long-form project documentation lives in [`docs/`](./docs/index.md).
|
|
|
85
85
|
|
|
86
86
|
## `createConfig()`
|
|
87
87
|
|
|
88
|
-
Use `createConfig()` when a project needs to customize root resolution,
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
Use `createConfig()` when a project needs to customize root resolution, import
|
|
89
|
+
resolver project paths, or plugin replacement/disabling while keeping the shared
|
|
90
|
+
defaults:
|
|
91
91
|
|
|
92
92
|
```js
|
|
93
|
-
import {
|
|
93
|
+
import {
|
|
94
|
+
allowDefaultProjectFilePatternPresets,
|
|
95
|
+
createConfig,
|
|
96
|
+
} from "eslint-config-nick2bad4u";
|
|
94
97
|
|
|
95
98
|
export default createConfig({
|
|
96
|
-
allowDefaultProjectFilePatterns:
|
|
97
|
-
|
|
98
|
-
"*.config.*.{js,mjs,cjs,ts,mts,cts}",
|
|
99
|
-
".*rc.{js,mjs,cjs,ts,mts,cts}",
|
|
100
|
-
"preset.mjs",
|
|
101
|
-
],
|
|
99
|
+
allowDefaultProjectFilePatterns:
|
|
100
|
+
allowDefaultProjectFilePatternPresets.rootScriptFiles,
|
|
102
101
|
rootDirectory: import.meta.dirname,
|
|
103
|
-
tsconfigPaths: ["./tsconfig.eslint.json"],
|
|
104
102
|
});
|
|
105
103
|
```
|
|
106
104
|
|
|
107
|
-
| Option | Type | Default | Use it when
|
|
108
|
-
| --------------------------------- | ----------------------------------- | ---------------------------- |
|
|
109
|
-
| `allowDefaultProjectFilePatterns` | `readonly string[]` |
|
|
110
|
-
| `rootDirectory` | `string` | `process.cwd()` | ESLint runs outside the project root or a monorepo package needs its own root.
|
|
111
|
-
| `tsconfigPaths` | `readonly string[]` | `["./tsconfig.eslint.json"]` |
|
|
112
|
-
| `plugins` | `Readonly<Record<string, unknown>>` | `{}` | You need to dogfood a local plugin build or disable packaged plugin rules by namespace.
|
|
105
|
+
| Option | Type | Default | Use it when |
|
|
106
|
+
| --------------------------------- | ----------------------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
107
|
+
| `allowDefaultProjectFilePatterns` | `readonly string[]` | Root JS/CJS/MJS globs | Root config files are intentionally outside the nearest `tsconfig.json`; keep this list tiny and avoid broad globs. |
|
|
108
|
+
| `rootDirectory` | `string` | `process.cwd()` | ESLint runs outside the project root or a monorepo package needs its own root. |
|
|
109
|
+
| `tsconfigPaths` | `readonly string[]` | `["./tsconfig.eslint.json"]` | Import resolver project paths; this does not replace TypeScript parser project-service discovery of `tsconfig.json`. |
|
|
110
|
+
| `plugins` | `Readonly<Record<string, unknown>>` | `{}` | You need to dogfood a local plugin build or disable packaged plugin rules by namespace. |
|
|
113
111
|
|
|
114
112
|
An example copy-paste config is available at
|
|
115
113
|
[`examples/eslint.config.create.mjs`](./examples/eslint.config.create.mjs).
|
|
@@ -151,14 +149,14 @@ needs to provide a local build of that plugin for dogfooding.
|
|
|
151
149
|
|
|
152
150
|
## TypeScript project setup
|
|
153
151
|
|
|
154
|
-
The
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
The TypeScript parser uses `projectService`, so typed linting follows
|
|
153
|
+
TypeScript's normal nearest-`tsconfig.json` lookup from `rootDirectory` or
|
|
154
|
+
`process.cwd()`. That `tsconfig.json` should include every TypeScript-aware file
|
|
155
|
+
ESLint can lint: source, tests, scripts, dotfiles, examples, and docs tooling.
|
|
157
156
|
|
|
158
157
|
```json
|
|
159
158
|
{
|
|
160
159
|
"$schema": "https://www.schemastore.org/tsconfig.json",
|
|
161
|
-
"extends": "./tsconfig.json",
|
|
162
160
|
"compilerOptions": {
|
|
163
161
|
"allowJs": true,
|
|
164
162
|
"checkJs": true,
|
|
@@ -169,9 +167,37 @@ can lint: source, tests, scripts, dotfiles, examples, and docs tooling.
|
|
|
169
167
|
}
|
|
170
168
|
```
|
|
171
169
|
|
|
172
|
-
|
|
170
|
+
If a repository keeps a separate `tsconfig.eslint.json`, that file can still be
|
|
171
|
+
useful for `tsconfigPaths` and import resolution, but it does not make the
|
|
172
|
+
parser project service pick that file instead of `tsconfig.json`. Put
|
|
173
|
+
lint-visible files in a nearest `tsconfig.json`, or opt a small number of root
|
|
174
|
+
files into `allowDefaultProjectFilePatterns`. The shared default already covers
|
|
175
|
+
root-only `js`, `mjs`, and `cjs` files, including dotfiles.
|
|
176
|
+
|
|
177
|
+
Override the default when a project wants a different root-only fallback:
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
import {
|
|
181
|
+
allowDefaultProjectFilePatternPresets,
|
|
182
|
+
createConfig,
|
|
183
|
+
} from "eslint-config-nick2bad4u";
|
|
184
|
+
|
|
185
|
+
export default createConfig({
|
|
186
|
+
allowDefaultProjectFilePatterns:
|
|
187
|
+
allowDefaultProjectFilePatternPresets.rootConfigFiles,
|
|
188
|
+
rootDirectory: import.meta.dirname,
|
|
189
|
+
});
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
`allowDefaultProjectFilePatternPresets.defaultRootFiles` matches the packaged
|
|
193
|
+
default. `rootScriptFiles` adds `ts`, `mts`, and `cts` for projects that know
|
|
194
|
+
those root files are outside `tsconfig.json`; `rootConfigFiles` and
|
|
195
|
+
`rootMjsFiles` are also available for narrower projects.
|
|
196
|
+
|
|
173
197
|
The `"**/.*"` include matters because dotfiles such as `.secretlintrc.cjs` are
|
|
174
|
-
not matched by extension globs like `**/*.cjs`.
|
|
198
|
+
not matched by extension globs like `**/*.cjs`. Do not use broad
|
|
199
|
+
`allowDefaultProjectFilePatterns` as a replacement for a correct `tsconfig.json`;
|
|
200
|
+
each default-project match has parser-service overhead.
|
|
175
201
|
|
|
176
202
|
Set `ESLINT_CONFIG_ROOT` only when you need to drive the root directory from the
|
|
177
203
|
environment instead of passing `rootDirectory` to `createConfig()`.
|
package/dist/preset.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
import { createConfig as createSharedConfig, configs as sharedConfigs, } from "./shared-config.js";
|
|
1
|
+
import { createConfig as createSharedConfig, allowDefaultProjectFilePatternPresets as sharedAllowDefaultProjectFilePatternPresets, configs as sharedConfigs, } from "./shared-config.js";
|
|
2
|
+
/** Opt-in file-pattern presets for TypeScript ESLint's default-project fallback. */
|
|
3
|
+
export const allowDefaultProjectFilePatternPresets = Object.freeze({
|
|
4
|
+
defaultRootFiles: [
|
|
5
|
+
...sharedAllowDefaultProjectFilePatternPresets.defaultRootFiles,
|
|
6
|
+
],
|
|
7
|
+
rootConfigFiles: [
|
|
8
|
+
...sharedAllowDefaultProjectFilePatternPresets.rootConfigFiles,
|
|
9
|
+
],
|
|
10
|
+
rootMjsFiles: [
|
|
11
|
+
...sharedAllowDefaultProjectFilePatternPresets.rootMjsFiles,
|
|
12
|
+
],
|
|
13
|
+
rootScriptFiles: [
|
|
14
|
+
...sharedAllowDefaultProjectFilePatternPresets.rootScriptFiles,
|
|
15
|
+
],
|
|
16
|
+
});
|
|
2
17
|
/** Shared flat config presets. */
|
|
3
18
|
export const presets = Object.freeze({
|
|
4
19
|
all: sharedConfigs.all,
|
|
@@ -28,6 +43,7 @@ export const presets = Object.freeze({
|
|
|
28
43
|
export const createConfig = (options) => createSharedConfig(options);
|
|
29
44
|
/** Default package export containing config presets and factory helper. */
|
|
30
45
|
const nickTwoBadFourU = Object.freeze({
|
|
46
|
+
allowDefaultProjectFilePatternPresets,
|
|
31
47
|
configs: presets,
|
|
32
48
|
createConfig,
|
|
33
49
|
});
|
package/dist/preset.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset.js","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,IAAI,kBAAkB,
|
|
1
|
+
{"version":3,"file":"preset.js","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,IAAI,kBAAkB,EAIlC,qCAAqC,IAAI,2CAA2C,EACpF,OAAO,IAAI,aAAa,GAC3B,MAAM,oBAAoB,CAAC;AAE5B,oFAAoF;AACpF,MAAM,CAAC,MAAM,qCAAqC,GAC9C,MAAM,CAAC,MAAM,CAAC;IACV,gBAAgB,EAAE;QACd,GAAG,2CAA2C,CAAC,gBAAgB;KAClE;IACD,eAAe,EAAE;QACb,GAAG,2CAA2C,CAAC,eAAe;KACjE;IACD,YAAY,EAAE;QACV,GAAG,2CAA2C,CAAC,YAAY;KAC9D;IACD,eAAe,EAAE;QACb,GAAG,2CAA2C,CAAC,eAAe;KACjE;CACJ,CAAC,CAAC;AAEP,kCAAkC;AAClC,MAAM,CAAC,MAAM,OAAO,GAAkC,MAAM,CAAC,MAAM,CAAC;IAChE,GAAG,EAAE,aAAa,CAAC,GAAG;IACtB,IAAI,EAAE,aAAa,CAAC,IAAI;IACxB,WAAW,EAAE,aAAa,CAAC,WAAW;IACtC,cAAc,EAAE,aAAa,CAAC,cAAc;IAC5C,kBAAkB,EAAE,aAAa,CAAC,kBAAkB;IACpD,cAAc,EAAE,aAAa,CAAC,cAAc;IAC5C,oBAAoB,EAAE,aAAa,CAAC,oBAAoB;IACxD,qBAAqB,EAAE,aAAa,CAAC,qBAAqB;IAC1D,qBAAqB,EAAE,aAAa,CAAC,qBAAqB;IAC1D,iBAAiB,EAAE,aAAa,CAAC,iBAAiB;IAClD,aAAa,EAAE,aAAa,CAAC,aAAa;IAC1C,WAAW,EAAE,aAAa,CAAC,WAAW;IACtC,qBAAqB,EAAE,aAAa,CAAC,qBAAqB;IAC1D,WAAW,EAAE,aAAa,CAAC,WAAW;IACtC,iBAAiB,EAAE,aAAa,CAAC,iBAAiB;IAClD,iBAAiB,EAAE,aAAa,CAAC,iBAAiB;IAClD,eAAe,EAAE,aAAa,CAAC,eAAe;IAC9C,oBAAoB,EAAE,aAAa,CAAC,oBAAoB;IACxD,cAAc,EAAE,aAAa,CAAC,cAAc;IAC5C,eAAe,EAAE,aAAa,CAAC,eAAe;IAC9C,WAAW,EAAE,aAAa,CAAC,WAAW;IACtC,yBAAyB,EAAE,aAAa,CAAC,yBAAyB;CACrE,CAAC,CAAC;AAEH,uDAAuD;AACvD,MAAM,CAAC,MAAM,YAAY,GAAG,CACxB,OAAuC,EACF,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAExE,2EAA2E;AAC3E,MAAM,eAAe,GAIjB,MAAM,CAAC,MAAM,CAAC;IACd,qCAAqC;IACrC,OAAO,EAAE,OAAO;IAChB,YAAY;CACf,CAAC,CAAC;AAEH,eAAe,eAAe,CAAC"}
|