eslint-config-nick2bad4u 1.2.7 → 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 CHANGED
@@ -3,20 +3,20 @@
3
3
  [![npm license.](https://flat.badgen.net/npm/license/eslint-config-nick2bad4u?color=purple)](https://github.com/Nick2bad4u/eslint-config-nick2bad4u/blob/main/LICENSE) [![npm total downloads.](https://flat.badgen.net/npm/dt/eslint-config-nick2bad4u?color=pink)](https://www.npmjs.com/package/eslint-config-nick2bad4u) [![latest GitHub release.](https://flat.badgen.net/github/release/Nick2bad4u/eslint-config-nick2bad4u?color=cyan)](https://github.com/Nick2bad4u/eslint-config-nick2bad4u/releases) [![GitHub stars.](https://flat.badgen.net/github/stars/Nick2bad4u/eslint-config-nick2bad4u?color=yellow)](https://github.com/Nick2bad4u/eslint-config-nick2bad4u/stargazers) [![GitHub forks.](https://flat.badgen.net/github/forks/Nick2bad4u/eslint-config-nick2bad4u?color=green)](https://github.com/Nick2bad4u/eslint-config-nick2bad4u/forks) [![GitHub open issues.](https://flat.badgen.net/github/open-issues/Nick2bad4u/eslint-config-nick2bad4u?color=red)](https://github.com/Nick2bad4u/eslint-config-nick2bad4u/issues) [![codecov.](https://codecov.io/gh/Nick2bad4u/eslint-config-nick2bad4u/branch/main/graph/badge.svg)](https://codecov.io/gh/Nick2bad4u/eslint-config-nick2bad4u)
4
4
 
5
5
  Shared ESM-only [ESLint flat config](https://eslint.org/docs/latest/use/configure/configuration-files)
6
- for Nick2bad4u ESLint plugin projects.
6
+ for Nick2bad4u TypeScript/JavaScript repositories.
7
7
 
8
8
  This package centralizes the lint stack used across those repositories: TypeScript-aware
9
- ESLint configuration, Markdown/JSON/YAML/CSS-adjacent linting, package checks,
10
- prose checks, and project-specific plugin presets. Consumers bring `eslint` and
11
- `typescript` as peer dependencies; this package brings the ESLint plugins and
12
- parsers that the shared config enables.
9
+ ESLint configuration, Markdown/JSON/YAML/TOML/CSS-adjacent linting, package
10
+ checks, prose checks, and project-specific plugin presets. Consumers bring
11
+ `eslint` and `typescript` as peer dependencies; this package brings the ESLint
12
+ plugins and parsers that the shared config enables.
13
13
 
14
14
  ## Requirements
15
15
 
16
16
  | Tool | Supported range | Why it is required |
17
17
  | ---------- | -------------------- | --------------------------------------------------------------- |
18
18
  | Node.js | `>=22.0.0` | Runtime for ESLint, the config package, and repository scripts. |
19
- | ESLint | `^10.4.0` | Peer dependency supplied by each consuming project. |
19
+ | ESLint | `^10.4.1` | Peer dependency supplied by each consuming project. |
20
20
  | TypeScript | `^5.0.0 \|\| ^6.0.3` | Peer dependency used by TypeScript-aware lint rules. |
21
21
 
22
22
  Repository development also expects npm `>=11.0.0`; consumers can use the package
@@ -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
- TypeScript project files, or plugin replacement/disabling while keeping the
90
- shared defaults:
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 { createConfig } from "eslint-config-nick2bad4u";
93
+ import {
94
+ allowDefaultProjectFilePatternPresets,
95
+ createConfig,
96
+ } from "eslint-config-nick2bad4u";
94
97
 
95
98
  export default createConfig({
96
- allowDefaultProjectFilePatterns: [
97
- "*.config.{js,mjs,cjs,ts,mts,cts}",
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[]` | `["*.mjs", ".*.mjs"]` | Root config files are intentionally outside `tsconfigPaths`; do not include files already covered by your lint tsconfig. |
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"]` | The project uses a differently named lint tsconfig or a truly separate TypeScript project. |
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 default TypeScript-aware configuration resolves from `process.cwd()` and
155
- expects `./tsconfig.eslint.json`. That project should include every file ESLint
156
- can lint: source, tests, scripts, dotfiles, examples, and docs tooling.
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
- One catch-all lint tsconfig is easier to maintain than multiple narrow projects.
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()`.
@@ -227,14 +253,17 @@ Use the aggregate scripts before opening a pull request or publishing:
227
253
 
228
254
  ```sh
229
255
  npm run lint:all
256
+ npm run lint:actions
230
257
  npm run release:verify
231
258
  ```
232
259
 
233
260
  `lint:all` builds the runtime, runs ESLint, typechecks, runs Vitest, checks
234
261
  Prettier formatting, validates package metadata and published package shape,
235
- lints YAML, and runs Secretlint. `release:verify` adds the stricter no-cache lint
236
- path, package checks with `publint` and ATTW, and sync checks for peer ranges and
237
- Node version files.
262
+ runs Gitleaks, and runs Secretlint. ESLint covers YAML through the shared config;
263
+ use `lint:yaml` or `lint:yamllint` when you need a targeted YAML-only pass.
264
+ `lint:actions` runs `actionlint` against GitHub workflows. `release:verify` uses
265
+ the stricter no-cache lint path, repeats strict package checks with `publint` and
266
+ ATTW, and syncs peer ranges and Node version files.
238
267
 
239
268
  Release notes are generated with `git-cliff` through the `changelog:*` scripts.
240
269
  For contribution and maintenance workflows, see the
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
  });
@@ -1 +1 @@
1
- {"version":3,"file":"preset.js","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,IAAI,kBAAkB,EAGlC,OAAO,IAAI,aAAa,GAC3B,MAAM,oBAAoB,CAAC;AAE5B,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,uDAA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