@kirill.konshin/lint 0.4.7 → 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 CHANGED
@@ -206,14 +206,14 @@ The Tailwind block auto-scopes to the **workspace package** owning the entry CSS
206
206
  ## Prettier `.prettierrc.mjs`:
207
207
 
208
208
  ```js
209
- import { prettier } from '@kirill.konshin/lint';
209
+ import { prettier } from '@kirill.konshin/lint/prettier';
210
210
  export default prettier;
211
211
  ```
212
212
 
213
213
  or
214
214
 
215
215
  ```js
216
- import { prettier } from '@kirill.konshin/lint';
216
+ import { prettier } from '@kirill.konshin/lint/prettier';
217
217
 
218
218
  export default {
219
219
  ...prettier,
@@ -221,6 +221,8 @@ export default {
221
221
  };
222
222
  ```
223
223
 
224
+ Import from `/prettier`, not the package root: the root loads every ESLint plugin, which would slow down each Prettier run.
225
+
224
226
  ## Editor Config `.editorconfig`
225
227
 
226
228
  ```editorconfig
@@ -270,10 +272,12 @@ indent_style = tab
270
272
  `.lintstagedrc.mjs`
271
273
 
272
274
  ```js
273
- import { listStaged } from '@kirill.konshin/lint';
275
+ import { listStaged } from '@kirill.konshin/lint/lint-staged';
274
276
  export default listStaged;
275
277
  ```
276
278
 
279
+ Import from `/lint-staged`, not the package root, for the same reason as `/prettier`. Tasks run the `eslint` / `prettier` scripts above through `node --run` (Node ≥ 22, `node_modules` linker), not `yarn`, which loads the whole project state before every script.
280
+
277
281
  ### Husky
278
282
 
279
283
  By default, always use the `prepare` script, as [Husky recommends](https://typicode.github.io/husky/get-started.html) — it never runs on consumers' installs of a published package, so it needs no guards. The bare `husky` command (v9+; `husky install` is the deprecated v8 form) installs the git hooks:
@@ -296,9 +300,11 @@ By default, always use the `prepare` script, as [Husky recommends](https://typic
296
300
 
297
301
  ```bash
298
302
  #!/bin/zsh
299
- yarn lint:staged
303
+ node --run lint:staged
300
304
  ```
301
305
 
306
+ Run scripts with `node --run` and tools directly (Husky puts `node_modules/.bin` on `PATH`): a `yarn` hop costs seconds.
307
+
302
308
  Note `source ~/.zshrc # for VSCode terminal` may be added for VSCode terminal that is not aware of ZSH. Do not add unless specifically asked, and remove if present.
303
309
 
304
310
  ## AI Agent Rules
@@ -404,7 +410,7 @@ Tool-gated functions take the same value as their `defineLintConfig` flag and ga
404
410
  Due to limitations package visibility between leaf and root this package has to be creative to support config-free detection.
405
411
 
406
412
  1. **Package probe** — `local-pkg`'s `isPackageExists` anchored at the **workspace root**, the same scope the plugins resolve from at lint time (`has<Pkg>` exported for debugging).
407
- 2. **Evidence scan** — tool config files across the workspace: the root directory plus every **workspace package** (the real `workspaces`/`pnpm-workspace.yaml` globs via `@manypkg/get-packages`, not a depth heuristic), skipping dot dirs, build outputs, and `.gitignore`d files; exported as `scanWorkspace`. Catches tools installed only in **leaf** packages, invisible to the probe (1). The workspace root itself comes from env (`PROJECT_CWD`/`npm_config_local_prefix`) with `@manypkg/find-root` as the fallback (workspace manifest walk, nearest `package.json` for single-package repos; exported as `findWorkspaceRoot`), so linting from inside a package still sees the whole repo.
413
+ 2. **Evidence scan** — tool config files across the workspace: the root directory plus every **workspace package** (the real `workspaces`/`pnpm-workspace.yaml` globs via `@manypkg/get-packages`, not a depth heuristic), skipping dot dirs, build outputs, and `.gitignore`d files; exported as `scanWorkspace`. All scans of a process share one filesystem cache, so each directory is read once. Catches tools installed only in **leaf** packages, invisible to the probe (1). The workspace root itself comes from env (`PROJECT_CWD`/`npm_config_local_prefix`) with `@manypkg/find-root` as the fallback (workspace manifest walk, nearest `package.json` for single-package repos; exported as `findWorkspaceRoot`), so linting from inside a package still sees the whole repo.
408
414
  3. **Hoisting, not bridging** — the plugins need the tool's package resolvable from the workspace root; a tool that is evidently in use (2) but not resolvable there (1) is a **hard error** with hoisting guidance (keep default hoisting, pnpm `public-hoist-pattern`, or a root devDependency — see the error text) instead of a silent skip or a cryptic plugin crash. Fix it once in the package manager config; nothing is symlinked at lint time.
409
415
  4. **Yarn Berry PnP** — there is no hoisting to configure; declare the tools at the workspace root as well, keeping versions in sync with the leaves (e.g. the `"vitest": "$vitest"` version-alias hack); `next` documents its own monorepo ESLint setup.
410
416
 
@@ -2,7 +2,7 @@ import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescrip
2
2
  import importXPlugin, { createNodeResolver } from 'eslint-plugin-import-x';
3
3
  import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
4
4
  import unusedImportsPlugin from 'eslint-plugin-unused-imports';
5
- import { tsExts } from '../lib.js';
5
+ import { tsExts } from '../exts.js';
6
6
  /**
7
7
  * Import linting via eslint-plugin-import-x: recommended rules + overrides + the default-export
8
8
  * relaxation for files that legitimately default-export (framework/tooling conventions) - the
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/configs/react.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,eAAO,MAAM,UAAU,kDAAsE,CAAC;AAe9F;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAWzD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,EAAE,OAAuC,EAAE,GAAE,WAAgB,GAAG,OAAO,CACxG,MAAM,CAAC,MAAM,EAAE,CAClB,CAOA;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,CAOjD;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,WAAW,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CA6BzG;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAAC,MAAM,EAAE,CAmD3D;AAED;;;;;GAKG;AAC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WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,WAAW,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAO1G"}
@@ -5,7 +5,8 @@ import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
5
5
  import reactPlugin from 'eslint-plugin-react';
6
6
  import reactHooksPlugin from 'eslint-plugin-react-hooks';
7
7
  import { globSync } from 'glob';
8
- import { findWorkspaceRoot, GLOBAL_IGNORES, hasNext, scanWorkspace, toolGate, tsExts } from '../lib.js';
8
+ import { tsExts } from '../exts.js';
9
+ import { findWorkspaceRoot, GLOBAL_IGNORES, hasNext, scanWorkspace, toolGate } from '../lib.js';
9
10
  // lazy so consumers without Next don't pay the load cost - re-exported from index.js
10
11
  export const nextPlugin = hasNext ? (await import('@next/eslint-plugin-next')).default : null;
11
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/configs/testing.ts"],"names":[],"mappings":"AAYA,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAC3C,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AA6DpC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,aAAa,EAAE,MAAM,UAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAgB5F;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,aAAa,EAAE,MAAM,UAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAsB9F;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,CAmB5C"}
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/configs/testing.ts"],"names":[],"mappings":"AAYA,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAC3C,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAG5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AA6DpC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,aAAa,EAAE,MAAM,UAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAgB5F;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,aAAa,EAAE,MAAM,UAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAsB9F;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,CAmB5C"}
@@ -12,7 +12,8 @@ import fs from 'node:fs';
12
12
  import path from 'node:path';
13
13
  import vitestPlugin from '@vitest/eslint-plugin';
14
14
  import jestPlugin from 'eslint-plugin-jest';
15
- import { GLOBAL_IGNORES, hasJest, hasVitest, scanWorkspace, toolGate, tsExts, tsExtsRaw } from '../lib.js';
15
+ import { tsExts, tsExtsRaw } from '../exts.js';
16
+ import { GLOBAL_IGNORES, hasJest, hasVitest, scanWorkspace, toolGate } from '../lib.js';
16
17
  export { jestPlugin, vitestPlugin };
17
18
  /*
18
19
  * Both runners use the evidence-based `toolGate` (see lib.js): a runner config file marks the repo
@@ -1,5 +1,5 @@
1
1
  import unicornPlugin from 'eslint-plugin-unicorn';
2
- import { tsExts } from '../lib.js';
2
+ import { tsExts } from '../exts.js';
3
3
  /**
4
4
  * Filename casing + node: protocol.
5
5
  *
package/dist/exts.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export declare const tsExtsRaw = "js,jsx,ts,tsx,cjs,cts,mjs,mts";
2
+ export declare const markupExtsRaw = "md,mdx,htm,html,vue";
3
+ export declare const eslintExtsRaw = "js,jsx,ts,tsx,cjs,cts,mjs,mts,md,mdx,htm,html,vue";
4
+ export declare const prettierExtsRaw = "css,scss,sass,less,yml,yaml,json,json5,jsonc,graphql,graphqls,xml";
5
+ export declare const tsExts = "{js,jsx,ts,tsx,cjs,cts,mjs,mts}";
6
+ export declare const eslintExts = "*.{js,jsx,ts,tsx,cjs,cts,mjs,mts,md,mdx,htm,html,vue}";
7
+ export declare const prettierExts = "*.{css,scss,sass,less,yml,yaml,json,json5,jsonc,graphql,graphqls,xml}";
8
+ //# sourceMappingURL=exts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exts.d.ts","sourceRoot":"","sources":["../src/exts.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,kCAAkC,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AACnD,eAAO,MAAM,aAAa,sDAAkC,CAAC;AAC7D,eAAO,MAAM,eAAe,sEAAsE,CAAC;AAEnG,eAAO,MAAM,MAAM,oCAAmB,CAAC;AACvC,eAAO,MAAM,UAAU,0DAAyB,CAAC;AACjD,eAAO,MAAM,YAAY,0EAA2B,CAAC"}
package/dist/exts.js ADDED
@@ -0,0 +1,11 @@
1
+ /*
2
+ * File extension lists shared by the ESLint blocks and the Prettier / lint-staged configs. Free of imports and side
3
+ * effects, so the `./prettier` and `./lint-staged` entries load nothing else.
4
+ */
5
+ export const tsExtsRaw = 'js,jsx,ts,tsx,cjs,cts,mjs,mts'; // TODO mdx, needs loader
6
+ export const markupExtsRaw = 'md,mdx,htm,html,vue';
7
+ export const eslintExtsRaw = `${tsExtsRaw},${markupExtsRaw}`;
8
+ export const prettierExtsRaw = 'css,scss,sass,less,yml,yaml,json,json5,jsonc,graphql,graphqls,xml';
9
+ export const tsExts = `{${tsExtsRaw}}`;
10
+ export const eslintExts = `*.{${eslintExtsRaw}}`;
11
+ export const prettierExts = `*.{${prettierExtsRaw}}`;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import type { ParserOptions as TsParserOptions } from '@typescript-eslint/parser';
2
2
  import type { Linter } from 'eslint';
3
3
  import type { PluginSettings as TailwindPluginSettings } from 'eslint-plugin-tailwindcss';
4
- import type { Configuration as LintStagedConfiguration } from 'lint-staged';
5
- import type { Config as PrettierConfig } from 'prettier';
6
4
  export * from './configs/base.js';
7
5
  export * from './configs/imports.js';
8
6
  export * from './configs/react.js';
@@ -15,7 +13,10 @@ export * from './configs/testing.js';
15
13
  export * from './configs/turbo.js';
16
14
  export * from './configs/typescriptTypeAware.js';
17
15
  export * from './configs/unicorn.js';
16
+ export * from './exts.js';
18
17
  export * from './lib.js';
18
+ export * from './lintStaged.js';
19
+ export * from './prettier.js';
19
20
  type ProjectServiceOptions = Exclude<NonNullable<TsParserOptions['projectService']>, boolean>;
20
21
  export type ToggleOptions = {
21
22
  enabled?: boolean;
@@ -63,18 +64,4 @@ export type LintOptions = {
63
64
  *
64
65
  */
65
66
  export declare function defineLintConfig(options?: LintOptions | Promise<LintOptions> | (() => LintOptions | Promise<LintOptions>)): Promise<Linter.Config[]>;
66
- export declare const prettier: PrettierConfig;
67
- /**
68
- * https://nextjs.org/docs/app/api-reference/config/eslint#running-lint-on-staged-files
69
- *
70
- * Pay extra attention when the configured globs overlap, and tasks make edits to files. Prettier and eslint might try
71
- * to make changes to the same *.ts file at the same time, causing a race condition.
72
- *
73
- * https://github.com/lint-staged/lint-staged?tab=readme-ov-file#reformatting-the-code
74
- * https://github.com/lint-staged/lint-staged/issues/775
75
- * You don't need git add since lint-staged 10
76
- *
77
- * TODO Screw yarn, just use eslint directly? Yarn gives greater control over what is in the console...
78
- */
79
- export declare const listStaged: LintStagedConfiguration;
80
67
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA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GACxC,IAAI,CACA,qBAAqB,EACrB,qBAAqB,GAAG,iEAAiE,CAC5F,GAAG;IACA,eAAe,CAAC,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAC;CACxD,CAAC;AAEN,MAAM,MAAM,oBAAoB,GAC5B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,CAAC,EAAE,IAAI,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3F,MAAM,MAAM,WAAW,GAAG;IACtB,SAAS,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;IACvC,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IACpC,KAAK,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IAChC,EAAE,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IAC/B,MAAM,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;IACrC,SAAS,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;IACvC,aAAa,CAAC,EAAE,OAAO,GAAG,oBAAoB,CAAC;CAClD,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAClC,OAAO,GAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAM,GAC9F,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAgD1B"}
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import { jestConfig, testConfig, vitestConfig } from './configs/testing.js';
10
10
  import { turboConfig } from './configs/turbo.js';
11
11
  import { typeAwareConfig } from './configs/typescriptTypeAware.js';
12
12
  import { unicornConfig } from './configs/unicorn.js';
13
- import { asOptions, eslintExts, prettierExts } from './lib.js';
13
+ import { asOptions } from './lib.js';
14
14
  export * from './configs/base.js';
15
15
  export * from './configs/imports.js';
16
16
  export * from './configs/react.js';
@@ -23,7 +23,10 @@ export * from './configs/testing.js';
23
23
  export * from './configs/turbo.js';
24
24
  export * from './configs/typescriptTypeAware.js';
25
25
  export * from './configs/unicorn.js';
26
+ export * from './exts.js';
26
27
  export * from './lib.js';
28
+ export * from './lintStaged.js';
29
+ export * from './prettier.js';
27
30
  /**
28
31
  * Build the shared flat ESLint config.
29
32
  *
@@ -81,33 +84,3 @@ export async function defineLintConfig(options = {}) {
81
84
  ...testConfig(),
82
85
  ];
83
86
  }
84
- export const prettier = {
85
- printWidth: 120,
86
- tabWidth: 2,
87
- singleQuote: true,
88
- proseWrap: 'never',
89
- overrides: [
90
- {
91
- files: eslintExts,
92
- options: {
93
- tabWidth: 4,
94
- },
95
- },
96
- ],
97
- };
98
- /**
99
- * https://nextjs.org/docs/app/api-reference/config/eslint#running-lint-on-staged-files
100
- *
101
- * Pay extra attention when the configured globs overlap, and tasks make edits to files. Prettier and eslint might try
102
- * to make changes to the same *.ts file at the same time, causing a race condition.
103
- *
104
- * https://github.com/lint-staged/lint-staged?tab=readme-ov-file#reformatting-the-code
105
- * https://github.com/lint-staged/lint-staged/issues/775
106
- * You don't need git add since lint-staged 10
107
- *
108
- * TODO Screw yarn, just use eslint directly? Yarn gives greater control over what is in the console...
109
- */
110
- export const listStaged = {
111
- [prettierExts]: ['yarn prettier'],
112
- [eslintExts]: ['yarn eslint', 'yarn prettier'],
113
- };
package/dist/lib.d.ts CHANGED
@@ -20,12 +20,6 @@ type ToolGateResult<T extends ToggleOptions> = {
20
20
  options: NormalizedOptions<T>;
21
21
  files: string[];
22
22
  };
23
- export declare const tsExtsRaw = "js,jsx,ts,tsx,cjs,cts,mjs,mts";
24
- export declare const eslintExtsRaw = "js,jsx,ts,tsx,cjs,cts,mjs,mts,md,mdx,htm,html,vue";
25
- export declare const prettierExtsRaw = "css,scss,sass,less,yml,yaml,json,json5,jsonc,graphql,graphqls,xml";
26
- export declare const tsExts = "{js,jsx,ts,tsx,cjs,cts,mjs,mts}";
27
- export declare const eslintExts = "*.{js,jsx,ts,tsx,cjs,cts,mjs,mts,md,mdx,htm,html,vue}";
28
- export declare const prettierExts = "*.{css,scss,sass,less,yml,yaml,json,json5,jsonc,graphql,graphqls,xml}";
29
23
  export declare const GLOBAL_IGNORES: string[];
30
24
  /**
31
25
  * Capability gate: is a package resolvable from the workspace root - the scope the ESLint plugins
package/dist/lib.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,KAAK,iBAAiB,CAAC,CAAC,SAAS,aAAa,IAAI,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AAErE,KAAK,YAAY,CAAC,CAAC,SAAS,aAAa,IAAI;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;IAChE,IAAI,CAAC,EAAE,MAAM,MAAM,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1D,CAAC;AAEF,KAAK,cAAc,CAAC,CAAC,SAAS,aAAa,IAAI;IAC3C,OAAO,EAAE,OAAO,CAAC;IAC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Ac,CAAC,CAAC,CAAC,CA6GnB"}
package/dist/lib.js CHANGED
@@ -5,12 +5,7 @@ import { findRootSync } from '@manypkg/find-root';
5
5
  import { getPackagesSync } from '@manypkg/get-packages';
6
6
  import { globSync } from 'glob';
7
7
  import { isPackageExists } from 'local-pkg';
8
- export const tsExtsRaw = 'js,jsx,ts,tsx,cjs,cts,mjs,mts'; // TODO mdx, needs loader
9
- export const eslintExtsRaw = `${tsExtsRaw},md,mdx,htm,html,vue`;
10
- export const prettierExtsRaw = 'css,scss,sass,less,yml,yaml,json,json5,jsonc,graphql,graphqls,xml';
11
- export const tsExts = `{${tsExtsRaw}}`;
12
- export const eslintExts = `*.{${eslintExtsRaw}}`;
13
- export const prettierExts = `*.{${prettierExtsRaw}}`;
8
+ import { PathScurry } from 'path-scurry';
14
9
  //TODO coverage, dist, out, build?
15
10
  export const GLOBAL_IGNORES = [
16
11
  '**/next-env.d.ts',
@@ -140,6 +135,20 @@ const SCAN_IGNORES = [
140
135
  '**/storybook-static',
141
136
  '**/.git',
142
137
  ];
138
+ const scurries = new Map();
139
+ /**
140
+ * Filesystem cache of a scanned directory, shared by every {@link scanWorkspace} call: the detection scans all walk
141
+ * the same trees, so each directory is read once instead of once per scan. Cached per process, like the workspace
142
+ * root and packages.
143
+ */
144
+ function scurryOf(dir) {
145
+ const cached = scurries.get(dir);
146
+ if (cached)
147
+ return cached;
148
+ const scurry = new PathScurry(dir);
149
+ scurries.set(dir, scurry);
150
+ return scurry;
151
+ }
143
152
  /**
144
153
  * Glob for config-file candidates across the workspace: the root directory plus every workspace
145
154
  * package (the real `workspaces` globs via {@link findWorkspacePackages}, not a depth heuristic),
@@ -176,8 +185,8 @@ export function scanWorkspace(fileGlob, ignores = [], { dot = false } = {}) {
176
185
  }),
177
186
  ];
178
187
  const files = [
179
- ...globSync(`**/${fileGlob}`, { cwd: root, ignore: rootIgnore, absolute: true, dot }),
180
- ...packages.flatMap((dir) => globSync(`**/${fileGlob}`, { cwd: dir, ignore, absolute: true, dot })),
188
+ ...globSync(`**/${fileGlob}`, { cwd: root, scurry: scurryOf(root), ignore: rootIgnore, absolute: true, dot }),
189
+ ...packages.flatMap((dir) => globSync(`**/${fileGlob}`, { cwd: dir, scurry: scurryOf(dir), ignore, absolute: true, dot })),
181
190
  ];
182
191
  // debug('scanWorkspace', { fileGlob, root, packages, dot, ignores, files });
183
192
  return files;
@@ -0,0 +1,22 @@
1
+ import type { Configuration as LintStagedConfiguration } from 'lint-staged';
2
+ /**
3
+ * Shared lint-staged config, the `@kirill.konshin/lint/lint-staged` entry. Import it from there, not the package root:
4
+ * the root loads every ESLint plugin, which would slow down each commit.
5
+ *
6
+ * Markup goes to Prettier only: no block of this config lints it, so ESLint would skip it with a warning, after its
7
+ * full startup.
8
+ *
9
+ * Tasks run the `eslint` / `prettier` package.json scripts (README), so their flags live in one place, through
10
+ * `node --run` rather than `yarn`: Yarn loads the whole project state before every script, seconds per commit.
11
+ *
12
+ * https://nextjs.org/docs/app/api-reference/config/eslint#running-lint-on-staged-files
13
+ *
14
+ * Pay extra attention when the configured globs overlap, and tasks make edits to files. Prettier and eslint might try
15
+ * to make changes to the same *.ts file at the same time, causing a race condition.
16
+ *
17
+ * https://github.com/lint-staged/lint-staged?tab=readme-ov-file#reformatting-the-code
18
+ * https://github.com/lint-staged/lint-staged/issues/775
19
+ * You don't need git add since lint-staged 10
20
+ */
21
+ export declare const listStaged: LintStagedConfiguration;
22
+ //# sourceMappingURL=lintStaged.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lintStaged.d.ts","sourceRoot":"","sources":["../src/lintStaged.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAI5E;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,EAAE,uBAGxB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { markupExtsRaw, prettierExtsRaw, tsExts } from './exts.js';
2
+ /**
3
+ * Shared lint-staged config, the `@kirill.konshin/lint/lint-staged` entry. Import it from there, not the package root:
4
+ * the root loads every ESLint plugin, which would slow down each commit.
5
+ *
6
+ * Markup goes to Prettier only: no block of this config lints it, so ESLint would skip it with a warning, after its
7
+ * full startup.
8
+ *
9
+ * Tasks run the `eslint` / `prettier` package.json scripts (README), so their flags live in one place, through
10
+ * `node --run` rather than `yarn`: Yarn loads the whole project state before every script, seconds per commit.
11
+ *
12
+ * https://nextjs.org/docs/app/api-reference/config/eslint#running-lint-on-staged-files
13
+ *
14
+ * Pay extra attention when the configured globs overlap, and tasks make edits to files. Prettier and eslint might try
15
+ * to make changes to the same *.ts file at the same time, causing a race condition.
16
+ *
17
+ * https://github.com/lint-staged/lint-staged?tab=readme-ov-file#reformatting-the-code
18
+ * https://github.com/lint-staged/lint-staged/issues/775
19
+ * You don't need git add since lint-staged 10
20
+ */
21
+ export const listStaged = {
22
+ [`*.{${prettierExtsRaw},${markupExtsRaw}}`]: ['node --run prettier --'],
23
+ [`*.${tsExts}`]: ['node --run eslint --', 'node --run prettier --'],
24
+ };
@@ -0,0 +1,7 @@
1
+ import type { Config as PrettierConfig } from 'prettier';
2
+ /**
3
+ * Shared Prettier config, the `@kirill.konshin/lint/prettier` entry. Import it from there, not the package root: the
4
+ * root loads every ESLint plugin, which would slow down each Prettier run.
5
+ */
6
+ export declare const prettier: PrettierConfig;
7
+ //# sourceMappingURL=prettier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettier.d.ts","sourceRoot":"","sources":["../src/prettier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,UAAU,CAAC;AAIzD;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,cAatB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { eslintExts } from './exts.js';
2
+ /**
3
+ * Shared Prettier config, the `@kirill.konshin/lint/prettier` entry. Import it from there, not the package root: the
4
+ * root loads every ESLint plugin, which would slow down each Prettier run.
5
+ */
6
+ export const prettier = {
7
+ printWidth: 120,
8
+ tabWidth: 2,
9
+ singleQuote: true,
10
+ proseWrap: 'never',
11
+ overrides: [
12
+ {
13
+ files: eslintExts,
14
+ options: {
15
+ tabWidth: 4,
16
+ },
17
+ },
18
+ ],
19
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kirill.konshin/lint",
3
3
  "description": "ESLint + Prettier + lint-staged config and AI agent rules/skills for monorepos",
4
- "version": "0.4.7",
4
+ "version": "0.5.0",
5
5
  "type": "module",
6
6
  "skipGenerate": true,
7
7
  "bin": {
@@ -15,6 +15,16 @@
15
15
  "types": "./dist/index.d.ts",
16
16
  "import": "./dist/index.js"
17
17
  },
18
+ "./lint-staged": {
19
+ "types": "./dist/lintStaged.d.ts",
20
+ "import": "./dist/lintStaged.js",
21
+ "default": "./dist/lintStaged.js"
22
+ },
23
+ "./prettier": {
24
+ "types": "./dist/prettier.d.ts",
25
+ "import": "./dist/prettier.js",
26
+ "default": "./dist/prettier.js"
27
+ },
18
28
  "./yarn": {
19
29
  "types": "./dist/yarn.d.cts",
20
30
  "require": "./dist/yarn.cjs"
@@ -62,7 +72,8 @@
62
72
  "glob": "^13.0.6",
63
73
  "globals": "^17.11.0",
64
74
  "jsonc-eslint-parser": "^3.3.0",
65
- "local-pkg": "^1.2.1"
75
+ "local-pkg": "^1.2.1",
76
+ "path-scurry": "^2.0.2"
66
77
  },
67
78
  "devDependencies": {
68
79
  "@types/eslint-plugin-jsx-a11y": "^6.10.1",
package/rules/webstorm.md CHANGED
@@ -197,3 +197,24 @@ Ban build directories from search using examples:
197
197
  </component>
198
198
  </project>
199
199
  ```
200
+
201
+ # Git Worktrees
202
+
203
+ `.idea/%projectName%.iml`, `.idea/modules.xml` and `.idea/.name` are usually tracked. Every git worktree therefore checks out a module with the same name as the main checkout's, and WebStorm refuses to attach it: `Cannot attach project: Module name '%projectName%' already exists`.
204
+
205
+ - When creating a worktree, ALWAYS give it a distinct module and project name derived from the branch, e.g. `Packing Travel App` for `travel-app`:
206
+ 1. **Rename** — do not copy — `.idea/%projectName%.iml` to `.idea/%projectName% %Branch Title%.iml`. The module name is the file name, and attaching the worktree registers whichever `.iml` it finds: a copy beside the original still attaches as `%projectName%`.
207
+ 2. Point `.idea/modules.xml` at the renamed file.
208
+ 3. Write the same name into `.idea/.name`.
209
+ 4. A main project the worktree is attached to lists it in its own `.idea/modules.xml`: point that entry at the renamed file too.
210
+ - Keep the rename local, and NEVER commit it or merge it back:
211
+ - The tracked `.iml` first: stage the branch's own edits to it (`git add .idea/%projectName%.iml`), then `git update-index --skip-worktree .idea/%projectName%.iml`, then rename. The staged content is what the branch commits; the rename never shows as a deletion. An edit the branch later makes to the renamed file has to be staged back the same way.
212
+ - Ignore the renamed file in the shared `.git/info/exclude` with the pattern `.idea/%projectName% *.iml`.
213
+ - A **tracked** `.idea/modules.xml` or `.idea/.name`: run `git update-index --skip-worktree` on it.
214
+ - An **untracked** one (often `modules.xml` is in `.idea/.gitignore` and `.name` does not exist yet): `skip-worktree` fails on it, so leave it to `.idea/.gitignore` or add it to the shared `.git/info/exclude` as well (e.g. `.idea/.name`).
215
+ - Verify with `git status --short .idea`: nothing from the rename is listed, only the staged edits.
216
+ - Before a rebase, merge or checkout that updates those files (tracked ones only):
217
+ 1. Rename the `.iml` back and run `git update-index --no-skip-worktree` on every file marked above.
218
+ 2. Restore them with `git checkout -- <files>`.
219
+ 3. Redo the rename afterwards.
220
+ - A worktree created **inside** the main checkout (e.g. `.claude/worktrees/<name>`, where agents put theirs) is indexed by the main project as part of itself, a second copy of every source and `node_modules`, and the main project's save actions start reformatting the worktree's files. Exclude its folder in the main checkout's `.idea/%projectName%.iml` (`<excludeFolder url="file://$MODULE_DIR$/.claude/worktrees" />`) and list it in `.gitignore`, so the folder rule under [GitIgnore](#gitignore) holds. Attaching such a worktree can replace the main checkout's own entry in its `.idea/modules.xml`: keep both — the main `.idea/%projectName%.iml` and the worktree's renamed one — then reload the project. A nested worktree shows as its own module node inside the tree, not as a separate top-level project; for a top-level entry, create the worktree outside the main checkout.