@kirill.konshin/lint 0.3.5 → 0.4.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 +135 -56
- package/dist/configs/base.d.ts +29 -0
- package/dist/configs/base.d.ts.map +1 -0
- package/{configs → dist/configs}/base.js +7 -25
- package/dist/configs/imports.d.ts +21 -0
- package/dist/configs/imports.d.ts.map +1 -0
- package/{configs → dist/configs}/imports.js +0 -10
- package/dist/configs/nx.d.ts +16 -0
- package/dist/configs/nx.d.ts.map +1 -0
- package/{configs → dist/configs}/nx.js +3 -8
- package/dist/configs/prettier.d.ts +17 -0
- package/dist/configs/prettier.d.ts.map +1 -0
- package/{configs → dist/configs}/prettier.js +0 -3
- package/dist/configs/promise.d.ts +6 -0
- package/dist/configs/promise.d.ts.map +1 -0
- package/{configs → dist/configs}/promise.js +0 -3
- package/dist/configs/react.d.ts +84 -0
- package/dist/configs/react.d.ts.map +1 -0
- package/{configs → dist/configs}/react.js +14 -41
- package/dist/configs/storybook.d.ts +14 -0
- package/dist/configs/storybook.d.ts.map +1 -0
- package/{configs → dist/configs}/storybook.js +3 -6
- package/dist/configs/tailwind.d.ts +29 -0
- package/dist/configs/tailwind.d.ts.map +1 -0
- package/{configs → dist/configs}/tailwind.js +9 -24
- package/dist/configs/testing.d.ts +22 -0
- package/dist/configs/testing.d.ts.map +1 -0
- package/{configs → dist/configs}/testing.js +11 -25
- package/dist/configs/turbo.d.ts +9 -0
- package/dist/configs/turbo.d.ts.map +1 -0
- package/{configs → dist/configs}/turbo.js +6 -6
- package/dist/configs/typescriptTypeAware.d.ts +20 -0
- package/dist/configs/typescriptTypeAware.d.ts.map +1 -0
- package/{configs → dist/configs}/typescriptTypeAware.js +10 -23
- package/dist/configs/unicorn.d.ts +10 -0
- package/dist/configs/unicorn.d.ts.map +1 -0
- package/{configs → dist/configs}/unicorn.js +0 -4
- package/dist/index.d.ts +80 -0
- package/dist/index.d.ts.map +1 -0
- package/{index.js → dist/index.js} +5 -54
- package/dist/lib.d.ts +116 -0
- package/dist/lib.d.ts.map +1 -0
- package/{lib.js → dist/lib.js} +69 -145
- package/dist/lintPrepare.d.ts +105 -0
- package/dist/lintPrepare.d.ts.map +1 -0
- package/{lintPrepare.js → dist/lintPrepare.js} +12 -67
- package/dist/yarn.cjs +117 -0
- package/dist/yarn.d.cts +8 -0
- package/dist/yarn.d.cts.map +1 -0
- package/package.json +42 -34
- package/rules/code-style.md +2 -0
- package/rules/github.md +17 -9
- package/rules/gitlab.md +68 -17
- package/rules/mui.md +1 -1
- package/rules/nextjs.md +1 -1
- package/rules/npm-yarn.md +51 -6
- package/rules/nx.md +6 -6
- package/rules/typescript.md +13 -7
- package/rules/webstorm.md +20 -0
- 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,52 +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
|
-
const FOOTER = `
|
|
42
|
-
---
|
|
36
|
+
const FOOTER = `---
|
|
43
37
|
|
|
44
38
|
# Custom Rules
|
|
45
39
|
|
|
46
40
|
Add your project-specific rules below the comment line.`;
|
|
47
|
-
|
|
48
41
|
const GENERATED_MARKER = '<!-- @kirill.konshin/lint:generated -->';
|
|
49
|
-
|
|
50
42
|
/**
|
|
51
43
|
* Read all markdown files from the package rules directory.
|
|
52
44
|
*/
|
|
53
45
|
export function readRules() {
|
|
54
46
|
const rules = [];
|
|
55
|
-
|
|
56
47
|
if (!fs.existsSync(RULES_DIR)) {
|
|
57
48
|
console.error(`Rules directory not found: ${RULES_DIR}`);
|
|
58
49
|
process.exit(1);
|
|
59
50
|
}
|
|
60
|
-
|
|
61
51
|
const files = fs
|
|
62
52
|
.readdirSync(RULES_DIR)
|
|
63
53
|
.filter((f) => f.endsWith('.md'))
|
|
64
54
|
.sort();
|
|
65
|
-
|
|
66
55
|
for (const file of files) {
|
|
67
56
|
const filePath = path.join(RULES_DIR, file);
|
|
68
57
|
const content = fs.readFileSync(filePath, 'utf-8');
|
|
@@ -72,34 +61,30 @@ export function readRules() {
|
|
|
72
61
|
content,
|
|
73
62
|
});
|
|
74
63
|
}
|
|
75
|
-
|
|
76
64
|
return rules;
|
|
77
65
|
}
|
|
78
|
-
|
|
79
66
|
/**
|
|
80
67
|
* Read all markdown files from the package skills directory. Each file becomes its own skill, named after the file
|
|
81
68
|
* (without extension) - e.g. `lint-repo.md` becomes the `lint-repo` skill.
|
|
82
69
|
*/
|
|
83
70
|
export function readSkills() {
|
|
84
|
-
if (!fs.existsSync(SKILLS_DIR))
|
|
85
|
-
|
|
71
|
+
if (!fs.existsSync(SKILLS_DIR))
|
|
72
|
+
return [];
|
|
86
73
|
return fs
|
|
87
74
|
.readdirSync(SKILLS_DIR)
|
|
88
75
|
.filter((f) => f.endsWith('.md'))
|
|
89
76
|
.sort()
|
|
90
77
|
.map((file) => ({ file, name: file.replace('.md', '') }));
|
|
91
78
|
}
|
|
92
|
-
|
|
93
79
|
/**
|
|
94
80
|
* Fail if `.claude/rules` contains anything that isn't a symlink - we don't want to
|
|
95
81
|
* silently blow away a real file/directory a user placed there by hand.
|
|
96
82
|
*/
|
|
97
83
|
export function checkRulesDirSafety(rulesTargetDir) {
|
|
98
|
-
if (!fs.existsSync(rulesTargetDir))
|
|
99
|
-
|
|
84
|
+
if (!fs.existsSync(rulesTargetDir))
|
|
85
|
+
return;
|
|
100
86
|
for (const entry of fs.readdirSync(rulesTargetDir)) {
|
|
101
87
|
const entryPath = path.join(rulesTargetDir, entry);
|
|
102
|
-
|
|
103
88
|
if (!fs.lstatSync(entryPath).isSymbolicLink()) {
|
|
104
89
|
console.error(`${CLAUDE_RULES_DIR}/${entry} exists and is not a symlink.`);
|
|
105
90
|
console.error('Remove or back it up manually, then re-run.');
|
|
@@ -107,26 +92,23 @@ export function checkRulesDirSafety(rulesTargetDir) {
|
|
|
107
92
|
}
|
|
108
93
|
}
|
|
109
94
|
}
|
|
110
|
-
|
|
111
95
|
/**
|
|
112
96
|
* Fail if `CLAUDE.md` exists and isn't a symlink - same reasoning as checkRulesDirSafety.
|
|
113
97
|
*/
|
|
114
98
|
export function checkClaudeMdSafety(claudeMdPath) {
|
|
115
99
|
let stat;
|
|
116
|
-
|
|
117
100
|
try {
|
|
118
101
|
stat = fs.lstatSync(claudeMdPath);
|
|
119
|
-
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
120
104
|
return;
|
|
121
105
|
}
|
|
122
|
-
|
|
123
106
|
if (!stat.isSymbolicLink()) {
|
|
124
107
|
console.error(`${CLAUDE_FILE} exists and is not a symlink.`);
|
|
125
108
|
console.error('Remove or back it up manually, then re-run.');
|
|
126
109
|
process.exit(1);
|
|
127
110
|
}
|
|
128
111
|
}
|
|
129
|
-
|
|
130
112
|
/**
|
|
131
113
|
* Symlink rules into the consuming project's `.claude/rules` directory.
|
|
132
114
|
* Safe to wipe and recreate: checkRulesDirSafety already guaranteed every existing
|
|
@@ -143,19 +125,15 @@ export function checkClaudeMdSafety(claudeMdPath) {
|
|
|
143
125
|
*/
|
|
144
126
|
export function symlinkRules(cwd, rules) {
|
|
145
127
|
const targetDir = path.join(cwd, CLAUDE_RULES_DIR);
|
|
146
|
-
|
|
147
128
|
fs.rmSync(targetDir, { recursive: true, force: true });
|
|
148
129
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
149
|
-
|
|
150
130
|
for (const rule of rules) {
|
|
151
131
|
const source = path.join(RULES_DIR, rule.file);
|
|
152
132
|
const linkPath = path.join(targetDir, rule.file);
|
|
153
133
|
fs.symlinkSync(path.relative(targetDir, source), linkPath);
|
|
154
134
|
}
|
|
155
|
-
|
|
156
135
|
return targetDir;
|
|
157
136
|
}
|
|
158
|
-
|
|
159
137
|
/**
|
|
160
138
|
* Fail if a skill's target directory (e.g. `.claude/skills/lint-repo`) contains anything
|
|
161
139
|
* that isn't a symlink - same reasoning as checkRulesDirSafety. Only the specific skill's
|
|
@@ -163,11 +141,10 @@ export function symlinkRules(cwd, rules) {
|
|
|
163
141
|
* parent, since other packages (or the user) may keep unrelated skills there.
|
|
164
142
|
*/
|
|
165
143
|
export function checkSkillDirSafety(skillDir) {
|
|
166
|
-
if (!fs.existsSync(skillDir))
|
|
167
|
-
|
|
144
|
+
if (!fs.existsSync(skillDir))
|
|
145
|
+
return;
|
|
168
146
|
for (const entry of fs.readdirSync(skillDir)) {
|
|
169
147
|
const entryPath = path.join(skillDir, entry);
|
|
170
|
-
|
|
171
148
|
if (!fs.lstatSync(entryPath).isSymbolicLink()) {
|
|
172
149
|
console.error(`${skillDir}/${entry} exists and is not a symlink.`);
|
|
173
150
|
console.error('Remove or back it up manually, then re-run.');
|
|
@@ -175,7 +152,6 @@ export function checkSkillDirSafety(skillDir) {
|
|
|
175
152
|
}
|
|
176
153
|
}
|
|
177
154
|
}
|
|
178
|
-
|
|
179
155
|
/**
|
|
180
156
|
* Symlink each package skill into `<cwd>/.claude/skills/<name>/` and
|
|
181
157
|
* `<cwd>/.codex/skills/<name>/`, so both Claude Code and Codex CLI can discover and run
|
|
@@ -185,42 +161,32 @@ export function checkSkillDirSafety(skillDir) {
|
|
|
185
161
|
export function symlinkSkills(cwd, skills) {
|
|
186
162
|
const targetDirs = [];
|
|
187
163
|
const hasReadme = fs.existsSync(README_FILE);
|
|
188
|
-
|
|
189
164
|
for (const skill of skills) {
|
|
190
165
|
for (const targetRoot of SKILLS_TARGET_DIRS) {
|
|
191
166
|
const skillDir = path.join(cwd, targetRoot, skill.name);
|
|
192
|
-
|
|
193
167
|
checkSkillDirSafety(skillDir);
|
|
194
|
-
|
|
195
168
|
fs.rmSync(skillDir, { recursive: true, force: true });
|
|
196
169
|
fs.mkdirSync(skillDir, { recursive: true });
|
|
197
|
-
|
|
198
170
|
const source = path.join(SKILLS_DIR, skill.file);
|
|
199
171
|
const linkPath = path.join(skillDir, 'SKILL.md');
|
|
200
172
|
fs.symlinkSync(path.relative(skillDir, source), linkPath);
|
|
201
|
-
|
|
202
173
|
if (hasReadme) {
|
|
203
174
|
const readmeLink = path.join(skillDir, 'README.md');
|
|
204
175
|
fs.symlinkSync(path.relative(skillDir, README_FILE), readmeLink);
|
|
205
176
|
}
|
|
206
|
-
|
|
207
177
|
targetDirs.push(skillDir);
|
|
208
178
|
}
|
|
209
179
|
}
|
|
210
|
-
|
|
211
180
|
return targetDirs;
|
|
212
181
|
}
|
|
213
|
-
|
|
214
182
|
/**
|
|
215
183
|
* Symlink CLAUDE.md -> AGENTS.md so both point at the same generated content.
|
|
216
184
|
*/
|
|
217
185
|
export function symlinkClaudeMd(cwd) {
|
|
218
186
|
const claudeMdPath = path.join(cwd, CLAUDE_FILE);
|
|
219
|
-
|
|
220
187
|
fs.rmSync(claudeMdPath, { force: true });
|
|
221
188
|
fs.symlinkSync(AGENTS_FILE, claudeMdPath);
|
|
222
189
|
}
|
|
223
|
-
|
|
224
190
|
/**
|
|
225
191
|
* Generate AGENTS.md with references to the rule files.
|
|
226
192
|
*
|
|
@@ -231,16 +197,11 @@ export function symlinkClaudeMd(cwd) {
|
|
|
231
197
|
*/
|
|
232
198
|
export function generateAgentsFile(rules, cwd, customSection) {
|
|
233
199
|
const relativeRulesDir = path.relative(cwd, RULES_DIR).split(path.sep).join('/');
|
|
234
|
-
|
|
235
200
|
const includes = rules.map((rule) => `@include ${relativeRulesDir}/${rule.file}`).join('\n');
|
|
236
|
-
|
|
237
201
|
const links = rules.map((rule) => `- [${rule.file}](${relativeRulesDir}/${rule.file})`).join('\n');
|
|
238
|
-
|
|
239
202
|
const generated = `${HEADER}\n\n${includes}\n\n${links}\n\n${FOOTER}\n\n${GENERATED_MARKER}`;
|
|
240
|
-
|
|
241
203
|
return customSection ? `${generated}\n\n${customSection}\n` : `${generated}\n`;
|
|
242
204
|
}
|
|
243
|
-
|
|
244
205
|
/**
|
|
245
206
|
* Check if AGENTS.md exists and was generated by this tool. When it was, also return
|
|
246
207
|
* whatever follows the marker (the user's custom section) so it can be carried forward -
|
|
@@ -251,15 +212,12 @@ export function checkExisting(targetPath) {
|
|
|
251
212
|
if (!fs.existsSync(targetPath)) {
|
|
252
213
|
return { exists: false, generated: false, customSection: null };
|
|
253
214
|
}
|
|
254
|
-
|
|
255
215
|
const content = fs.readFileSync(targetPath, 'utf-8');
|
|
256
216
|
const markerIndex = content.indexOf(GENERATED_MARKER);
|
|
257
217
|
const generated = markerIndex !== -1;
|
|
258
218
|
const customSection = generated ? content.slice(markerIndex + GENERATED_MARKER.length).trim() : null;
|
|
259
|
-
|
|
260
219
|
return { exists: true, generated, customSection };
|
|
261
220
|
}
|
|
262
|
-
|
|
263
221
|
/**
|
|
264
222
|
* Main function
|
|
265
223
|
*/
|
|
@@ -270,56 +228,43 @@ export function main() {
|
|
|
270
228
|
const targetPath = path.join(cwd, AGENTS_FILE);
|
|
271
229
|
const claudeMdPath = path.join(cwd, CLAUDE_FILE);
|
|
272
230
|
const rulesTargetDir = path.join(cwd, CLAUDE_RULES_DIR);
|
|
273
|
-
|
|
274
231
|
console.log(`@kirill.konshin/lint: ${command}`);
|
|
275
232
|
console.log(`Target: ${targetPath}`);
|
|
276
|
-
|
|
277
233
|
const { exists, generated, customSection } = checkExisting(targetPath);
|
|
278
|
-
|
|
279
234
|
if (command === 'init') {
|
|
280
235
|
if (exists && !generated) {
|
|
281
236
|
console.log(`${AGENTS_FILE} exists and was not generated by this tool. Skipping.`);
|
|
282
237
|
console.log('Use "lint-prepare update" to force overwrite, then merge manually.');
|
|
283
238
|
return;
|
|
284
239
|
}
|
|
285
|
-
|
|
286
240
|
if (exists && generated) {
|
|
287
241
|
console.log(`${AGENTS_FILE} exists and was generated by this tool. Updating...`);
|
|
288
242
|
}
|
|
289
243
|
}
|
|
290
|
-
|
|
291
244
|
if (command === 'update' || command === 'init') {
|
|
292
245
|
checkRulesDirSafety(rulesTargetDir);
|
|
293
246
|
checkClaudeMdSafety(claudeMdPath);
|
|
294
|
-
|
|
295
247
|
const rules = readRules();
|
|
296
248
|
console.log(`Found ${rules.length} rule files: ${rules.map((r) => r.name).join(', ')}`);
|
|
297
|
-
|
|
298
249
|
const targetRulesDir = symlinkRules(cwd, rules);
|
|
299
250
|
console.log(`Symlinked rules to ${targetRulesDir}`);
|
|
300
|
-
|
|
301
251
|
const skills = readSkills();
|
|
302
252
|
console.log(`Found ${skills.length} skill(s): ${skills.map((s) => s.name).join(', ')}`);
|
|
303
|
-
|
|
304
253
|
const targetSkillDirs = symlinkSkills(cwd, skills);
|
|
305
254
|
for (const targetSkillDir of targetSkillDirs) {
|
|
306
255
|
console.log(`Symlinked skill to ${targetSkillDir}`);
|
|
307
256
|
}
|
|
308
|
-
|
|
309
257
|
const content = generateAgentsFile(rules, cwd, customSection);
|
|
310
258
|
fs.writeFileSync(targetPath, content, 'utf-8');
|
|
311
259
|
console.log(`${exists ? 'Updated' : 'Created'} ${AGENTS_FILE}`);
|
|
312
|
-
|
|
313
260
|
symlinkClaudeMd(cwd);
|
|
314
261
|
console.log(`Symlinked ${CLAUDE_FILE} -> ${AGENTS_FILE}`);
|
|
315
262
|
return;
|
|
316
263
|
}
|
|
317
|
-
|
|
318
264
|
console.log(`Unknown command: ${command}`);
|
|
319
265
|
console.log('Usage: lint-prepare [init|update]');
|
|
320
266
|
process.exit(1);
|
|
321
267
|
}
|
|
322
|
-
|
|
323
268
|
// Only run when executed directly (e.g. `lint-prepare init`), not when imported.
|
|
324
269
|
if (process.argv[1] && fs.realpathSync(process.argv[1]) === fs.realpathSync(__filename)) {
|
|
325
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
|
+
}
|
package/dist/yarn.d.cts
ADDED
|
@@ -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.
|
|
4
|
+
"version": "0.4.0",
|
|
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": "
|
|
17
|
-
"start": "
|
|
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
|
-
"
|
|
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/
|
|
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.
|
|
37
|
-
"@nx/eslint-plugin": "
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
39
|
-
"@typescript-eslint/parser": "^8.
|
|
40
|
-
"@vitest/eslint-plugin": "^1.6.
|
|
41
|
-
"
|
|
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.
|
|
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.
|
|
55
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
50
56
|
"eslint-plugin-simple-import-sort": "^14.0.0",
|
|
51
|
-
"eslint-plugin-storybook": "^10.5.
|
|
57
|
+
"eslint-plugin-storybook": "^10.5.7",
|
|
52
58
|
"eslint-plugin-tailwindcss": "^4.2.0",
|
|
53
|
-
"eslint-plugin-turbo": "^2.10.
|
|
54
|
-
"eslint-plugin-unicorn": "^
|
|
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": "^
|
|
58
|
-
"jsonc-eslint-parser": "^
|
|
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
|
-
"
|
|
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
|
|
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": {
|
package/rules/code-style.md
CHANGED
|
@@ -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/github.md
CHANGED
|
@@ -57,13 +57,6 @@ jobs:
|
|
|
57
57
|
id: yarn-cache-dir-path
|
|
58
58
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
|
59
59
|
|
|
60
|
-
- name: Install dependencies
|
|
61
|
-
run: yarn install --immutable
|
|
62
|
-
|
|
63
|
-
# Add this if Yarn 2+ is used and package is NOT private
|
|
64
|
-
- name: Prepare
|
|
65
|
-
run: yarn prepare
|
|
66
|
-
|
|
67
60
|
- uses: actions/cache@v6
|
|
68
61
|
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
|
69
62
|
with:
|
|
@@ -72,13 +65,28 @@ jobs:
|
|
|
72
65
|
restore-keys: |
|
|
73
66
|
${{ runner.os }}-yarn-
|
|
74
67
|
|
|
75
|
-
|
|
68
|
+
#TODO https://turbo.build/repo/docs/guides/ci-vendors/github-actions#remote-caching
|
|
76
69
|
#TODO https://turborepo.dev/docs/guides/ci-vendors/github-actions#remote-caching-with-github-actionscache
|
|
77
|
-
- name: Cache
|
|
70
|
+
- name: Cache Turbo
|
|
78
71
|
uses: actions/cache@v6
|
|
79
72
|
with:
|
|
80
73
|
path: .turbo
|
|
81
74
|
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
|
82
75
|
restore-keys: |
|
|
83
76
|
${{ runner.os }}-turbo-
|
|
77
|
+
|
|
78
|
+
- name: Cache NX
|
|
79
|
+
uses: actions/cache@v6
|
|
80
|
+
with:
|
|
81
|
+
path: .nx
|
|
82
|
+
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
|
83
|
+
restore-keys: |
|
|
84
|
+
${{ runner.os }}-turbo-
|
|
85
|
+
|
|
86
|
+
- name: Install dependencies
|
|
87
|
+
run: yarn install --immutable
|
|
88
|
+
|
|
89
|
+
# Add this if Yarn 2+ is used and package is NOT private, otherwise postinstall should be configured, and this block skipped
|
|
90
|
+
- name: Prepare
|
|
91
|
+
run: yarn prepare
|
|
84
92
|
```
|