@kirill.konshin/lint 0.3.6 → 0.4.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.
Files changed (58) hide show
  1. package/README.md +137 -57
  2. package/dist/configs/base.d.ts +29 -0
  3. package/dist/configs/base.d.ts.map +1 -0
  4. package/{configs → dist/configs}/base.js +7 -25
  5. package/dist/configs/imports.d.ts +21 -0
  6. package/dist/configs/imports.d.ts.map +1 -0
  7. package/{configs → dist/configs}/imports.js +0 -10
  8. package/dist/configs/nx.d.ts +16 -0
  9. package/dist/configs/nx.d.ts.map +1 -0
  10. package/{configs → dist/configs}/nx.js +3 -8
  11. package/dist/configs/prettier.d.ts +17 -0
  12. package/dist/configs/prettier.d.ts.map +1 -0
  13. package/{configs → dist/configs}/prettier.js +0 -3
  14. package/dist/configs/promise.d.ts +6 -0
  15. package/dist/configs/promise.d.ts.map +1 -0
  16. package/{configs → dist/configs}/promise.js +0 -3
  17. package/dist/configs/react.d.ts +84 -0
  18. package/dist/configs/react.d.ts.map +1 -0
  19. package/{configs → dist/configs}/react.js +14 -41
  20. package/dist/configs/storybook.d.ts +14 -0
  21. package/dist/configs/storybook.d.ts.map +1 -0
  22. package/{configs → dist/configs}/storybook.js +3 -6
  23. package/dist/configs/tailwind.d.ts +29 -0
  24. package/dist/configs/tailwind.d.ts.map +1 -0
  25. package/{configs → dist/configs}/tailwind.js +9 -24
  26. package/dist/configs/testing.d.ts +22 -0
  27. package/dist/configs/testing.d.ts.map +1 -0
  28. package/{configs → dist/configs}/testing.js +11 -25
  29. package/dist/configs/turbo.d.ts +9 -0
  30. package/dist/configs/turbo.d.ts.map +1 -0
  31. package/{configs → dist/configs}/turbo.js +6 -6
  32. package/dist/configs/typescriptTypeAware.d.ts +20 -0
  33. package/dist/configs/typescriptTypeAware.d.ts.map +1 -0
  34. package/{configs → dist/configs}/typescriptTypeAware.js +10 -23
  35. package/dist/configs/unicorn.d.ts +10 -0
  36. package/dist/configs/unicorn.d.ts.map +1 -0
  37. package/{configs → dist/configs}/unicorn.js +0 -4
  38. package/dist/index.d.ts +80 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/{index.js → dist/index.js} +5 -54
  41. package/dist/lib.d.ts +116 -0
  42. package/dist/lib.d.ts.map +1 -0
  43. package/{lib.js → dist/lib.js} +69 -145
  44. package/dist/lintPrepare.d.ts +105 -0
  45. package/dist/lintPrepare.d.ts.map +1 -0
  46. package/{lintPrepare.js → dist/lintPrepare.js} +11 -65
  47. package/dist/yarn.cjs +117 -0
  48. package/dist/yarn.d.cts +8 -0
  49. package/dist/yarn.d.cts.map +1 -0
  50. package/package.json +42 -34
  51. package/rules/code-style.md +2 -0
  52. package/rules/mui.md +1 -1
  53. package/rules/nextjs.md +1 -1
  54. package/rules/npm-yarn.md +36 -6
  55. package/rules/nx.md +6 -6
  56. package/rules/typescript.md +13 -7
  57. package/rules/webstorm.md +20 -0
  58. package/index.d.ts +0 -281
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
-
3
2
  /**
4
3
  * @kirill.konshin/lint
5
4
  *
@@ -17,51 +16,42 @@
17
16
  * The module also exports its functions and only runs `main()` when executed directly,
18
17
  * so it can be imported (for testing/reuse) without side effects.
19
18
  */
20
-
21
19
  import fs from 'node:fs';
22
20
  import path from 'node:path';
23
21
  import { fileURLToPath } from 'node:url';
24
-
25
22
  const __filename = fileURLToPath(import.meta.url);
26
23
  const __dirname = path.dirname(__filename);
27
-
28
24
  const AGENTS_FILE = 'AGENTS.md';
29
25
  const CLAUDE_FILE = 'CLAUDE.md';
30
26
  const CLAUDE_RULES_DIR = '.claude/rules';
31
- const RULES_DIR = path.join(__dirname, 'rules');
32
- const SKILLS_DIR = path.join(__dirname, 'skills');
33
- const README_FILE = path.join(__dirname, 'README.md');
27
+ const RULES_DIR = path.join(__dirname, '../rules');
28
+ const SKILLS_DIR = path.join(__dirname, '../skills');
29
+ const README_FILE = path.join(__dirname, '../README.md');
34
30
  const SKILLS_TARGET_DIRS = ['.claude/skills', '.codex/skills'];
35
31
  const HEADER = `# AI Agent Rules
36
32
 
37
33
  This file is auto-generated by @kirill.konshin/lint. Do not edit directly - customize by adding your own rules below the generated section.
38
34
 
39
35
  ---`;
40
-
41
36
  const FOOTER = `---
42
37
 
43
38
  # Custom Rules
44
39
 
45
40
  Add your project-specific rules below the comment line.`;
46
-
47
41
  const GENERATED_MARKER = '<!-- @kirill.konshin/lint:generated -->';
48
-
49
42
  /**
50
43
  * Read all markdown files from the package rules directory.
51
44
  */
52
45
  export function readRules() {
53
46
  const rules = [];
54
-
55
47
  if (!fs.existsSync(RULES_DIR)) {
56
48
  console.error(`Rules directory not found: ${RULES_DIR}`);
57
49
  process.exit(1);
58
50
  }
59
-
60
51
  const files = fs
61
52
  .readdirSync(RULES_DIR)
62
53
  .filter((f) => f.endsWith('.md'))
63
54
  .sort();
64
-
65
55
  for (const file of files) {
66
56
  const filePath = path.join(RULES_DIR, file);
67
57
  const content = fs.readFileSync(filePath, 'utf-8');
@@ -71,34 +61,30 @@ export function readRules() {
71
61
  content,
72
62
  });
73
63
  }
74
-
75
64
  return rules;
76
65
  }
77
-
78
66
  /**
79
67
  * Read all markdown files from the package skills directory. Each file becomes its own skill, named after the file
80
68
  * (without extension) - e.g. `lint-repo.md` becomes the `lint-repo` skill.
81
69
  */
82
70
  export function readSkills() {
83
- if (!fs.existsSync(SKILLS_DIR)) return [];
84
-
71
+ if (!fs.existsSync(SKILLS_DIR))
72
+ return [];
85
73
  return fs
86
74
  .readdirSync(SKILLS_DIR)
87
75
  .filter((f) => f.endsWith('.md'))
88
76
  .sort()
89
77
  .map((file) => ({ file, name: file.replace('.md', '') }));
90
78
  }
91
-
92
79
  /**
93
80
  * Fail if `.claude/rules` contains anything that isn't a symlink - we don't want to
94
81
  * silently blow away a real file/directory a user placed there by hand.
95
82
  */
96
83
  export function checkRulesDirSafety(rulesTargetDir) {
97
- if (!fs.existsSync(rulesTargetDir)) return;
98
-
84
+ if (!fs.existsSync(rulesTargetDir))
85
+ return;
99
86
  for (const entry of fs.readdirSync(rulesTargetDir)) {
100
87
  const entryPath = path.join(rulesTargetDir, entry);
101
-
102
88
  if (!fs.lstatSync(entryPath).isSymbolicLink()) {
103
89
  console.error(`${CLAUDE_RULES_DIR}/${entry} exists and is not a symlink.`);
104
90
  console.error('Remove or back it up manually, then re-run.');
@@ -106,26 +92,23 @@ export function checkRulesDirSafety(rulesTargetDir) {
106
92
  }
107
93
  }
108
94
  }
109
-
110
95
  /**
111
96
  * Fail if `CLAUDE.md` exists and isn't a symlink - same reasoning as checkRulesDirSafety.
112
97
  */
113
98
  export function checkClaudeMdSafety(claudeMdPath) {
114
99
  let stat;
115
-
116
100
  try {
117
101
  stat = fs.lstatSync(claudeMdPath);
118
- } catch {
102
+ }
103
+ catch {
119
104
  return;
120
105
  }
121
-
122
106
  if (!stat.isSymbolicLink()) {
123
107
  console.error(`${CLAUDE_FILE} exists and is not a symlink.`);
124
108
  console.error('Remove or back it up manually, then re-run.');
125
109
  process.exit(1);
126
110
  }
127
111
  }
128
-
129
112
  /**
130
113
  * Symlink rules into the consuming project's `.claude/rules` directory.
131
114
  * Safe to wipe and recreate: checkRulesDirSafety already guaranteed every existing
@@ -142,19 +125,15 @@ export function checkClaudeMdSafety(claudeMdPath) {
142
125
  */
143
126
  export function symlinkRules(cwd, rules) {
144
127
  const targetDir = path.join(cwd, CLAUDE_RULES_DIR);
145
-
146
128
  fs.rmSync(targetDir, { recursive: true, force: true });
147
129
  fs.mkdirSync(targetDir, { recursive: true });
148
-
149
130
  for (const rule of rules) {
150
131
  const source = path.join(RULES_DIR, rule.file);
151
132
  const linkPath = path.join(targetDir, rule.file);
152
133
  fs.symlinkSync(path.relative(targetDir, source), linkPath);
153
134
  }
154
-
155
135
  return targetDir;
156
136
  }
157
-
158
137
  /**
159
138
  * Fail if a skill's target directory (e.g. `.claude/skills/lint-repo`) contains anything
160
139
  * that isn't a symlink - same reasoning as checkRulesDirSafety. Only the specific skill's
@@ -162,11 +141,10 @@ export function symlinkRules(cwd, rules) {
162
141
  * parent, since other packages (or the user) may keep unrelated skills there.
163
142
  */
164
143
  export function checkSkillDirSafety(skillDir) {
165
- if (!fs.existsSync(skillDir)) return;
166
-
144
+ if (!fs.existsSync(skillDir))
145
+ return;
167
146
  for (const entry of fs.readdirSync(skillDir)) {
168
147
  const entryPath = path.join(skillDir, entry);
169
-
170
148
  if (!fs.lstatSync(entryPath).isSymbolicLink()) {
171
149
  console.error(`${skillDir}/${entry} exists and is not a symlink.`);
172
150
  console.error('Remove or back it up manually, then re-run.');
@@ -174,7 +152,6 @@ export function checkSkillDirSafety(skillDir) {
174
152
  }
175
153
  }
176
154
  }
177
-
178
155
  /**
179
156
  * Symlink each package skill into `<cwd>/.claude/skills/<name>/` and
180
157
  * `<cwd>/.codex/skills/<name>/`, so both Claude Code and Codex CLI can discover and run
@@ -184,42 +161,32 @@ export function checkSkillDirSafety(skillDir) {
184
161
  export function symlinkSkills(cwd, skills) {
185
162
  const targetDirs = [];
186
163
  const hasReadme = fs.existsSync(README_FILE);
187
-
188
164
  for (const skill of skills) {
189
165
  for (const targetRoot of SKILLS_TARGET_DIRS) {
190
166
  const skillDir = path.join(cwd, targetRoot, skill.name);
191
-
192
167
  checkSkillDirSafety(skillDir);
193
-
194
168
  fs.rmSync(skillDir, { recursive: true, force: true });
195
169
  fs.mkdirSync(skillDir, { recursive: true });
196
-
197
170
  const source = path.join(SKILLS_DIR, skill.file);
198
171
  const linkPath = path.join(skillDir, 'SKILL.md');
199
172
  fs.symlinkSync(path.relative(skillDir, source), linkPath);
200
-
201
173
  if (hasReadme) {
202
174
  const readmeLink = path.join(skillDir, 'README.md');
203
175
  fs.symlinkSync(path.relative(skillDir, README_FILE), readmeLink);
204
176
  }
205
-
206
177
  targetDirs.push(skillDir);
207
178
  }
208
179
  }
209
-
210
180
  return targetDirs;
211
181
  }
212
-
213
182
  /**
214
183
  * Symlink CLAUDE.md -> AGENTS.md so both point at the same generated content.
215
184
  */
216
185
  export function symlinkClaudeMd(cwd) {
217
186
  const claudeMdPath = path.join(cwd, CLAUDE_FILE);
218
-
219
187
  fs.rmSync(claudeMdPath, { force: true });
220
188
  fs.symlinkSync(AGENTS_FILE, claudeMdPath);
221
189
  }
222
-
223
190
  /**
224
191
  * Generate AGENTS.md with references to the rule files.
225
192
  *
@@ -230,16 +197,11 @@ export function symlinkClaudeMd(cwd) {
230
197
  */
231
198
  export function generateAgentsFile(rules, cwd, customSection) {
232
199
  const relativeRulesDir = path.relative(cwd, RULES_DIR).split(path.sep).join('/');
233
-
234
200
  const includes = rules.map((rule) => `@include ${relativeRulesDir}/${rule.file}`).join('\n');
235
-
236
201
  const links = rules.map((rule) => `- [${rule.file}](${relativeRulesDir}/${rule.file})`).join('\n');
237
-
238
202
  const generated = `${HEADER}\n\n${includes}\n\n${links}\n\n${FOOTER}\n\n${GENERATED_MARKER}`;
239
-
240
203
  return customSection ? `${generated}\n\n${customSection}\n` : `${generated}\n`;
241
204
  }
242
-
243
205
  /**
244
206
  * Check if AGENTS.md exists and was generated by this tool. When it was, also return
245
207
  * whatever follows the marker (the user's custom section) so it can be carried forward -
@@ -250,15 +212,12 @@ export function checkExisting(targetPath) {
250
212
  if (!fs.existsSync(targetPath)) {
251
213
  return { exists: false, generated: false, customSection: null };
252
214
  }
253
-
254
215
  const content = fs.readFileSync(targetPath, 'utf-8');
255
216
  const markerIndex = content.indexOf(GENERATED_MARKER);
256
217
  const generated = markerIndex !== -1;
257
218
  const customSection = generated ? content.slice(markerIndex + GENERATED_MARKER.length).trim() : null;
258
-
259
219
  return { exists: true, generated, customSection };
260
220
  }
261
-
262
221
  /**
263
222
  * Main function
264
223
  */
@@ -269,56 +228,43 @@ export function main() {
269
228
  const targetPath = path.join(cwd, AGENTS_FILE);
270
229
  const claudeMdPath = path.join(cwd, CLAUDE_FILE);
271
230
  const rulesTargetDir = path.join(cwd, CLAUDE_RULES_DIR);
272
-
273
231
  console.log(`@kirill.konshin/lint: ${command}`);
274
232
  console.log(`Target: ${targetPath}`);
275
-
276
233
  const { exists, generated, customSection } = checkExisting(targetPath);
277
-
278
234
  if (command === 'init') {
279
235
  if (exists && !generated) {
280
236
  console.log(`${AGENTS_FILE} exists and was not generated by this tool. Skipping.`);
281
237
  console.log('Use "lint-prepare update" to force overwrite, then merge manually.');
282
238
  return;
283
239
  }
284
-
285
240
  if (exists && generated) {
286
241
  console.log(`${AGENTS_FILE} exists and was generated by this tool. Updating...`);
287
242
  }
288
243
  }
289
-
290
244
  if (command === 'update' || command === 'init') {
291
245
  checkRulesDirSafety(rulesTargetDir);
292
246
  checkClaudeMdSafety(claudeMdPath);
293
-
294
247
  const rules = readRules();
295
248
  console.log(`Found ${rules.length} rule files: ${rules.map((r) => r.name).join(', ')}`);
296
-
297
249
  const targetRulesDir = symlinkRules(cwd, rules);
298
250
  console.log(`Symlinked rules to ${targetRulesDir}`);
299
-
300
251
  const skills = readSkills();
301
252
  console.log(`Found ${skills.length} skill(s): ${skills.map((s) => s.name).join(', ')}`);
302
-
303
253
  const targetSkillDirs = symlinkSkills(cwd, skills);
304
254
  for (const targetSkillDir of targetSkillDirs) {
305
255
  console.log(`Symlinked skill to ${targetSkillDir}`);
306
256
  }
307
-
308
257
  const content = generateAgentsFile(rules, cwd, customSection);
309
258
  fs.writeFileSync(targetPath, content, 'utf-8');
310
259
  console.log(`${exists ? 'Updated' : 'Created'} ${AGENTS_FILE}`);
311
-
312
260
  symlinkClaudeMd(cwd);
313
261
  console.log(`Symlinked ${CLAUDE_FILE} -> ${AGENTS_FILE}`);
314
262
  return;
315
263
  }
316
-
317
264
  console.log(`Unknown command: ${command}`);
318
265
  console.log('Usage: lint-prepare [init|update]');
319
266
  process.exit(1);
320
267
  }
321
-
322
268
  // Only run when executed directly (e.g. `lint-prepare init`), not when imported.
323
269
  if (process.argv[1] && fs.realpathSync(process.argv[1]) === fs.realpathSync(__filename)) {
324
270
  main();
package/dist/yarn.cjs ADDED
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineYarnConfig = defineYarnConfig;
4
+ const DEFAULT_CONSISTENT_DEPENDENCIES = [
5
+ '@types/node',
6
+ '@types/react',
7
+ '@types/react-dom',
8
+ 'next',
9
+ 'eslint',
10
+ 'typescript',
11
+ 'vite',
12
+ ];
13
+ const ROOT_CWD = '.';
14
+ const DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
15
+ function dependencyIdent(selector) {
16
+ const match = selector.match(/(?:^|\/)((?:@[^/]+\/)?[^/@]+)(?:@.+)?$/);
17
+ return match?.[1] ?? null;
18
+ }
19
+ function rootDependencyRange(root, ident) {
20
+ for (const field of DEPENDENCY_FIELDS) {
21
+ const range = root.manifest[field]?.[ident];
22
+ if (typeof range === 'string')
23
+ return range;
24
+ }
25
+ return null;
26
+ }
27
+ function overrideRange(root, value) {
28
+ if (!value.startsWith('$'))
29
+ return value;
30
+ const ident = value.slice(1);
31
+ const range = rootDependencyRange(root, ident);
32
+ if (range === null)
33
+ root.error(`Override ${value} must reference a root dependency`);
34
+ return range;
35
+ }
36
+ function collectOverrides(root, overrides, ranges) {
37
+ for (const [selector, value] of Object.entries(overrides)) {
38
+ if (typeof value === 'string') {
39
+ const ident = dependencyIdent(selector);
40
+ const range = overrideRange(root, value);
41
+ if (ident !== null && range !== null)
42
+ ranges.set(ident, range);
43
+ continue;
44
+ }
45
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) {
46
+ root.error(`Override ${selector} must be a string or object`);
47
+ continue;
48
+ }
49
+ const nestedOverrides = value;
50
+ if (typeof nestedOverrides['.'] === 'string') {
51
+ const ident = dependencyIdent(selector);
52
+ const range = overrideRange(root, nestedOverrides['.']);
53
+ if (ident !== null && range !== null)
54
+ ranges.set(ident, range);
55
+ }
56
+ collectOverrides(root, Object.fromEntries(Object.entries(nestedOverrides).filter(([nestedSelector]) => nestedSelector !== '.')), ranges);
57
+ }
58
+ }
59
+ function collectResolutions(root, ranges) {
60
+ for (const [selector, range] of Object.entries(root.manifest.resolutions ?? {})) {
61
+ const ident = dependencyIdent(selector);
62
+ if (ident === null || typeof range !== 'string') {
63
+ root.error(`Resolution ${selector} must map to a string range`);
64
+ continue;
65
+ }
66
+ ranges.set(ident, range);
67
+ }
68
+ }
69
+ function comparableDependencies(yarn, ident) {
70
+ return yarn.dependencies({ ident }).filter((dependency) => dependency.type !== 'peerDependencies');
71
+ }
72
+ function fallbackRange(root, dependencies) {
73
+ const rootRange = dependencies.find((dependency) => dependency.workspace.cwd === ROOT_CWD)?.range;
74
+ if (rootRange !== undefined)
75
+ return rootRange;
76
+ return [...dependencies].sort((a, b) => a.workspace.cwd.localeCompare(b.workspace.cwd) || a.type.localeCompare(b.type))[0]?.range;
77
+ }
78
+ /**
79
+ * Build a Yarn JavaScript constraints config that mirrors root overrides and resolutions in leaf
80
+ * dependency declarations. Without an overrides field, the default dependency set is kept on one
81
+ * consistent range instead.
82
+ */
83
+ function defineYarnConfig() {
84
+ return {
85
+ async constraints({ Yarn }) {
86
+ const root = Yarn.workspace({ cwd: ROOT_CWD });
87
+ if (root === null)
88
+ throw new Error('Yarn constraints could not find the root workspace');
89
+ const ranges = new Map();
90
+ collectResolutions(root, ranges);
91
+ if (Object.hasOwn(root.manifest, 'overrides')) {
92
+ const overrides = root.manifest.overrides;
93
+ if (overrides === null || typeof overrides !== 'object' || Array.isArray(overrides)) {
94
+ root.error('Root overrides must be an object');
95
+ }
96
+ else {
97
+ collectOverrides(root, overrides, ranges);
98
+ }
99
+ }
100
+ else {
101
+ for (const ident of DEFAULT_CONSISTENT_DEPENDENCIES) {
102
+ if (ranges.has(ident))
103
+ continue;
104
+ const range = fallbackRange(root, comparableDependencies(Yarn, ident));
105
+ if (range !== undefined)
106
+ ranges.set(ident, range);
107
+ }
108
+ }
109
+ for (const [ident, range] of ranges) {
110
+ for (const dependency of comparableDependencies(Yarn, ident)) {
111
+ if (dependency.workspace.cwd !== ROOT_CWD)
112
+ dependency.update(range);
113
+ }
114
+ }
115
+ },
116
+ };
117
+ }
@@ -0,0 +1,8 @@
1
+ import type { Yarn } from '@yarnpkg/types';
2
+ /**
3
+ * Build a Yarn JavaScript constraints config that mirrors root overrides and resolutions in leaf
4
+ * dependency declarations. Without an overrides field, the default dependency set is kept on one
5
+ * consistent range instead.
6
+ */
7
+ export declare function defineYarnConfig(): Yarn.Config;
8
+ //# sourceMappingURL=yarn.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yarn.d.cts","sourceRoot":"","sources":["../src/yarn.cts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AA8F3C;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAAC,MAAM,CA+B9C"}
package/package.json CHANGED
@@ -1,78 +1,86 @@
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.3.6",
4
+ "version": "0.4.1",
5
5
  "type": "module",
6
6
  "skipGenerate": true,
7
7
  "bin": {
8
- "lint-prepare": "./lintPrepare.js"
8
+ "lint-prepare": "./dist/lintPrepare.js"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "module": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ },
18
+ "./yarn": {
19
+ "types": "./dist/yarn.d.cts",
20
+ "require": "./dist/yarn.cjs"
21
+ }
9
22
  },
10
- "main": "index.js",
11
- "module": "index.js",
12
- "types": "index.d.ts",
13
23
  "scripts": {
14
24
  "----- BUILD -----": "",
15
25
  "clean": "rm -rf dist .tscache tsconfig.tsbuildinfo",
16
- "build": "echo 'No build required'",
17
- "start": "echo 'No start required'",
26
+ "build": "tsc --build",
27
+ "start": "tsc --build --watch",
18
28
  "----- TEST -----": "",
19
- "test": "vitest run"
29
+ "test": "yarn build && vitest run"
20
30
  },
21
31
  "files": [
22
- "index.js",
23
- "index.d.ts",
24
- "configs",
25
- "!configs/*.test.js",
26
- "lib.js",
27
- "lintPrepare.js",
32
+ "dist",
28
33
  "rules",
29
34
  "skills"
30
35
  ],
31
36
  "dependencies": {
32
- "@eslint/compat": "^2.0.3",
37
+ "@eslint/config-helpers": "^0.7.0",
33
38
  "@eslint/js": "^10.0.1",
34
39
  "@manypkg/find-root": "^3.1.0",
35
40
  "@manypkg/get-packages": "^3.1.0",
36
- "@next/eslint-plugin-next": "^16.2.1",
37
- "@nx/eslint-plugin": "^23.1.0",
38
- "@typescript-eslint/eslint-plugin": "^8.57.2",
39
- "@typescript-eslint/parser": "^8.57.2",
40
- "@vitest/eslint-plugin": "^1.6.23",
41
- "eslint-config-next": "^16.2.1",
41
+ "@next/eslint-plugin-next": "^16.3.0",
42
+ "@nx/eslint-plugin": "23.2.0-beta.7",
43
+ "@typescript-eslint/eslint-plugin": "^8.67.0",
44
+ "@typescript-eslint/parser": "^8.67.0",
45
+ "@vitest/eslint-plugin": "^1.6.27",
46
+ "@yarnpkg/types": "^4.0.1",
47
+ "eslint-config-next": "^16.3.0",
42
48
  "eslint-config-prettier": "^10.1.8",
43
49
  "eslint-import-resolver-typescript": "^4.4.5",
44
50
  "eslint-plugin-import-x": "^4.17.1",
45
- "eslint-plugin-jest": "^29.15.4",
51
+ "eslint-plugin-jest": "^29.16.1",
46
52
  "eslint-plugin-jsx-a11y": "^6.10.2",
47
53
  "eslint-plugin-promise": "^7.3.0",
48
54
  "eslint-plugin-react": "^7.37.5",
49
- "eslint-plugin-react-hooks": "^7.0.1",
55
+ "eslint-plugin-react-hooks": "^7.1.1",
50
56
  "eslint-plugin-simple-import-sort": "^14.0.0",
51
- "eslint-plugin-storybook": "^10.5.2",
57
+ "eslint-plugin-storybook": "^10.5.7",
52
58
  "eslint-plugin-tailwindcss": "^4.2.0",
53
- "eslint-plugin-turbo": "^2.10.5",
54
- "eslint-plugin-unicorn": "^72.0.0",
59
+ "eslint-plugin-turbo": "^2.10.9",
60
+ "eslint-plugin-unicorn": "^73.0.0",
55
61
  "eslint-plugin-unused-imports": "^4.4.1",
56
62
  "glob": "^13.0.6",
57
- "globals": "^16.4.0",
58
- "jsonc-eslint-parser": "^2.4.2",
63
+ "globals": "^17.11.0",
64
+ "jsonc-eslint-parser": "^3.3.0",
59
65
  "local-pkg": "^1.2.1"
60
66
  },
61
67
  "devDependencies": {
62
- "vitest": "*"
68
+ "@types/eslint-plugin-jsx-a11y": "^6.10.1",
69
+ "@types/eslint-plugin-promise": "^7.3.0",
70
+ "vitest": "^4.1.10"
63
71
  },
64
72
  "peerDependencies": {
65
73
  "eslint": "^10",
66
74
  "husky": "^9",
67
- "jest": "*",
75
+ "jest": "^30",
68
76
  "lint-staged": "^16",
69
77
  "next": "^16",
70
78
  "prettier": "^3",
71
- "storybook": "^10.5.2",
72
- "tailwindcss": "*",
79
+ "storybook": "^10",
80
+ "tailwindcss": "^4",
73
81
  "typescript": "^6",
74
- "vite": "*",
75
- "vitest": "*"
82
+ "vite": "^8",
83
+ "vitest": "^4"
76
84
  },
77
85
  "peerDependenciesMeta": {
78
86
  "jest": {
@@ -4,3 +4,5 @@ description: Set of rules for ALL projects
4
4
  ---
5
5
 
6
6
  - When generating code respect max length set in `.editorconfig` or `.prettierrc` (could be with extension)
7
+ - Always wrap configurations in `defineConfig` if provided to ensure type safety (eslint, vite, vitest, jest, playwright, yarn, etc.)
8
+ - Prefer TS-based configurations if possible (next.js, vite, vitest)
package/rules/mui.md CHANGED
@@ -19,4 +19,4 @@ paths:
19
19
  # Next.js
20
20
 
21
21
  - When MUI is used with Next.js ALWAYS add barrel-heavy packages to `experimental.optimizePackageImports`: `@mui/material`, `@mui/system`, `@mui/icons-material`, `@mui/lab`, `@mui/x-data-grid`, `@toolpad/core`, plus the other usual suspects (`@fortawesome/*`, `@gravity-ui/icons`, `@gravity-ui/uikit`, `lodash`, `@heroui/react`, `react-bootstrap`, `@kirill.konshin/icons`)
22
- - Prefer `defineNextConfig` from `@kirill.konshin/next` which sets the exhaustive list — extra entries are ignored, missing ones cost dev startup and bundle size (see nextjs.md)
22
+ - Prefer `defineNextConfig` from `@kirill.konshin/next/config` which sets the exhaustive list — extra entries are ignored, missing ones cost dev startup and bundle size (see nextjs.md)
package/rules/nextjs.md CHANGED
@@ -13,7 +13,7 @@ _EVERY_ Next.js page, layout, route handler or component must adhere to policy u
13
13
  - Use `iron-session` for authentication via `@kirill.konshin/auth`, see auth.md
14
14
  - Server-only modules (auth/session, DB access, anything touching secrets) MUST start with `import 'server-only'` (the npm package, add as dependency) — ENFORCED BY AGENT: no ESLint rule checks this, add it when creating such modules and flag it when reviewing
15
15
  - `package.json` MUST ALWAYS have version of Next.js, NEVER `*`, otherwise Vercel will fall into legacy mode instead of serverless
16
- - ALWAYS create `next.config.ts` with `defineNextConfig` from `@kirill.konshin/next`: sets `cacheComponents`, `typedRoutes`, `experimental.typedEnv`, `reactStrictMode: false` and an exhaustive `experimental.optimizePackageImports` (`@mui/*`, `@toolpad/core`, `@fortawesome/*`, `@gravity-ui/*`, `lodash`, `@heroui/react`, `react-bootstrap`, `@kirill.konshin/icons` — extra entries are ignored, missing ones cost dev startup and bundle size, see mui.md)
16
+ - ALWAYS create `next.config.ts` with `defineNextConfig` from `@kirill.konshin/next/config` (the `/config` subpath, NEVER the barrel — Next transpiles `next.config.ts` to CJS and `require`s it outside any bundler): sets `cacheComponents`, `typedRoutes`, `experimental.typedEnv`, `reactStrictMode: false` and an exhaustive `experimental.optimizePackageImports` (`@mui/*`, `@toolpad/core`, `@fortawesome/*`, `@gravity-ui/*`, `lodash`, `@heroui/react`, `react-bootstrap`, `@kirill.konshin/icons` — extra entries are ignored, missing ones cost dev startup and bundle size, see mui.md)
17
17
  - Use `@kirill.konshin/icons` for FontAwesome / Gravity UI icons — the barrel is safe with `optimizePackageImports` (`defineNextConfig` sets it)
18
18
 
19
19
  # Admin Pages & Login
package/rules/npm-yarn.md CHANGED
@@ -30,10 +30,9 @@ description: NPM & Yarn patterns
30
30
 
31
31
  # Consistent versions
32
32
 
33
- In Monorepos pin versions of sub-packages to main. Listed packages were seen to cause issues when versions drift.
33
+ In monorepos pin versions of sub-packages to the root; these packages cause issues when versions drift.
34
34
 
35
- https://github.com/raineorshine/npm-check-updates/issues/1332#issuecomment-1717862332
36
- https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
35
+ https://github.com/raineorshine/npm-check-updates/issues/1332#issuecomment-1717862332 https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
37
36
 
38
37
  Root `package.json`:
39
38
 
@@ -65,13 +64,25 @@ All other `package.json`:
65
64
  ```jsonc
66
65
  {
67
66
  "devDependencies": {
68
- "next": "16.0.0", // except next, see nextjs.md
69
- "typescript": "*", // vividly express version does not matter
67
+ "next": "^16.0.0", // except next, see nextjs.md
68
+ "typescript": "^6.0.0",
70
69
  },
71
70
  }
72
71
  ```
73
72
 
74
- ⚠️ Attention! Yarn does not support `overrides` with `$xxx` syntax, use `resolutions` instead. AI Agent MUST keep versions listed in `resolutions` in sync with real ones from `dependencies` and `devDependencies`, if it breaks anything, drop `resolutions` field and fix by changing actual dependencies in leaves to match root.
73
+ Yarn does not apply npm `overrides`; `defineYarnConfig` reads them as constraints together with `resolutions`, keeps non-peer leaf ranges equal, and falls back to the listed default packages when `overrides` is absent.
74
+
75
+ Every package with `"packageManager": "yarn@..."` MUST directly install `@yarnpkg/types` and use:
76
+
77
+ ```js
78
+ /** @type {import('@yarnpkg/types')} */
79
+ const { defineConfig } = require('@yarnpkg/types');
80
+ const { defineYarnConfig } = require('@kirill.konshin/lint/yarn');
81
+
82
+ module.exports = defineConfig(defineYarnConfig());
83
+ ```
84
+
85
+ Run `yarn constraints --fix` after dependency changes.
75
86
 
76
87
  # `.yarnrc.yml`
77
88
 
@@ -93,3 +104,22 @@ npmMinimalAgeGate: 0
93
104
  npmPreapprovedPackages:
94
105
  - '@kirill.konshin/*'
95
106
  ```
107
+
108
+ # Yalc (Local Package Linking)
109
+
110
+ Test unpublished packages in sibling projects (yalc is a root devDependency here):
111
+
112
+ 1. `yarn nx run @kirill.konshin/<pkg>:build`
113
+ 2. `cd packages/<pkg> && yarn yalc publish` (after changes: `yarn yalc publish --push` updates all linked consumers)
114
+ 3. In the consumer: `npx yalc link @kirill.konshin/<pkg>` (or the yalc binary from this repo)
115
+
116
+ Rules:
117
+
118
+ - ALWAYS use `yalc link` (symlink mode: `node_modules/<pkg>` → local `.yalc/<pkg>` copy), NEVER `yalc add` — `add` writes `file:.yalc/...` into package.json
119
+ - While linked, `package.json`, `yarn.lock` and `.yarnrc.yml` MUST NOT be modified by the link — link artifacts break CI/other machines and must NEVER be committed; gitignore `.yalc/` and `yalc.lock` in the consumer
120
+ - The real dependency (e.g. `"@kirill.konshin/auth": "^0.0.1"`) is committed separately; the consumer's `yarn.lock` can only be updated after the version is actually published to npm
121
+ - The consumer resolves the linked package's own dependencies from its node_modules — they must be installed there (usually already are as the consumer's own deps)
122
+ - A later `yarn install` in the consumer removes the symlink — re-run `yalc link`
123
+ - Unlinking: `yalc remove --all` cleans `.yalc/` and `yalc.lock` but leaves dangling symlinks in `node_modules` — delete them before `yarn install`
124
+ - Yarn 4.17+ quarantines packages published <24h ago (`npmMinimalAgeGate`) — consumers need `npmPreapprovedPackages: ["@kirill.konshin/*"]` in `.yarnrc.yml` to install own packages right after release (older Yarn errors on that key — upgrade the consumer via `packageManager` first)
125
+ - `.yarnrc.local.yml` is NOT a thing (open Yarn feature request, local overrides only via `YARN_*` env vars) and yalc runs NO registry (it is a file store in `~/.yalc`), so a registry override cannot replace linking — `yalc link` is the only mode that leaves all manifests untouched