@kirill.konshin/lint 0.1.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 +203 -0
- package/index.js +657 -0
- package/lintPrepare.js +326 -0
- package/package.json +94 -0
- package/ruleTestColocation.js +50 -0
- package/rules/code-style.md +6 -0
- package/rules/electron.md +25 -0
- package/rules/expo.md +4 -0
- package/rules/github.md +71 -0
- package/rules/gitlab.md +37 -0
- package/rules/i18n.md +6 -0
- package/rules/jest.md +9 -0
- package/rules/monorepo-turbo-nx.md +56 -0
- package/rules/mui.md +10 -0
- package/rules/nextjs.md +69 -0
- package/rules/npm-yarn.md +61 -0
- package/rules/nx.md +31 -0
- package/rules/react.md +87 -0
- package/rules/redux.md +4 -0
- package/rules/storybook.md +38 -0
- package/rules/tailwind.md +17 -0
- package/rules/testing.md +25 -0
- package/rules/turbo.md +58 -0
- package/rules/typescript.md +95 -0
- package/rules/vite.md +21 -0
- package/rules/webstorm.md +133 -0
- package/skills/lint-repo.md +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# @kirill.konshin/lint
|
|
2
|
+
|
|
3
|
+
ESLint + Prettier + lint-staged + Husky configuration, plus AI agent rules & skills for monorepos — in one package.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
$ yarn add -D eslint prettier @kirill.konshin/lint husky lint-staged
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### PNPM
|
|
12
|
+
|
|
13
|
+
https://eslint.org/docs/latest/use/getting-started#manual-set-up
|
|
14
|
+
|
|
15
|
+
```dotenv
|
|
16
|
+
auto-install-peers=true
|
|
17
|
+
node-linker=hoisted
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## ESLint / Prettier / lint-staged / Husky
|
|
21
|
+
|
|
22
|
+
### Settings
|
|
23
|
+
|
|
24
|
+
`eslint.config.mjs`:
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import { defineConfig } from 'eslint/config';
|
|
28
|
+
import customConfig, { nextPlugin, includeIgnoreFile, tsExts } from '@kirill.konshin/lint';
|
|
29
|
+
|
|
30
|
+
export default defineConfig([
|
|
31
|
+
...customConfig,
|
|
32
|
+
{
|
|
33
|
+
files: [`**/*.${tsExts}`],
|
|
34
|
+
plugins: {
|
|
35
|
+
next: nextPlugin,
|
|
36
|
+
},
|
|
37
|
+
settings: {
|
|
38
|
+
next: {
|
|
39
|
+
rootDir: process.cwd() + '/path/to/next-app',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Custom rules',
|
|
45
|
+
rules: {
|
|
46
|
+
// overrides
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
includeIgnoreFile(import.meta.url, '.gitignore'),
|
|
50
|
+
includeIgnoreFile(import.meta.url, '.prettierignore'),
|
|
51
|
+
]);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`.prettierrc.mjs`:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
import { prettier } from '@kirill.konshin/lint';
|
|
58
|
+
export default prettier;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
or
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
import { prettier } from '@kirill.konshin/lint';
|
|
65
|
+
|
|
66
|
+
export default {
|
|
67
|
+
...prettier,
|
|
68
|
+
// overrides
|
|
69
|
+
};
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`.editorconfig`
|
|
73
|
+
|
|
74
|
+
```editorconfig
|
|
75
|
+
root = true
|
|
76
|
+
|
|
77
|
+
[*]
|
|
78
|
+
indent_style = space
|
|
79
|
+
end_of_line = lf
|
|
80
|
+
charset = utf-8
|
|
81
|
+
trim_trailing_whitespace = true
|
|
82
|
+
insert_final_newline = false
|
|
83
|
+
|
|
84
|
+
[*.{js,jsx,ts,tsx,cjs,cts,mjs,mts,md,mdx,htm,html,vue}]
|
|
85
|
+
indent_size = 4
|
|
86
|
+
|
|
87
|
+
[*.{css,scss,sass,less,yml,yaml,json,json5,graphql,graphqls,xml}]
|
|
88
|
+
indent_size = 2
|
|
89
|
+
|
|
90
|
+
[Makefile]
|
|
91
|
+
indent_style = tab
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`package.json`:
|
|
95
|
+
|
|
96
|
+
```jsonc
|
|
97
|
+
{
|
|
98
|
+
"scripts": {
|
|
99
|
+
"eslint": "eslint --fix --concurrency=auto --cache --cache-location node_modules/.cache/eslint", // to see files use --debug
|
|
100
|
+
"prettier": "prettier --write --log-level=warn --ignore-path .gitignore --ignore-path .prettierignore", // to see files use --log-level=log
|
|
101
|
+
"lint": "yarn eslint . && yarn prettier .",
|
|
102
|
+
"lint:staged": "lint-staged",
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### IDEA settings
|
|
108
|
+
|
|
109
|
+
- Eslint: `**/*.{js,jsx,ts,tsx,cjs,cts,mjs,mts,md,mdx,htm,html,vue}`
|
|
110
|
+
- Prettier: `{**/*,*}.{js,jsx,ts,tsx,cjs,cts,mjs,mts,md,mdx,htm,html,vue,css,scss,sass,less,yml,yaml,json,json5,graphql,graphqls,xml}`
|
|
111
|
+
|
|
112
|
+
### Lint Staged
|
|
113
|
+
|
|
114
|
+
`.lintstagedrc.mjs`
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
import { listStaged } from '@kirill.konshin/lint';
|
|
118
|
+
export default listStaged;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Husky
|
|
122
|
+
|
|
123
|
+
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:
|
|
124
|
+
|
|
125
|
+
`package.json`:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"scripts": {
|
|
130
|
+
"prepare": "lint-prepare init && husky && next types"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
> ⚠️ `next types` is optional and should only be added if project uses Next.js typed routes, as additional measure, types will be generated anyway
|
|
136
|
+
|
|
137
|
+
> ⚠️ Yarn 2+ (Berry) skips top-level `prepare` on install ([lifecycle scripts](https://yarnpkg.com/advanced/lifecycle-scripts)) — run `yarn prepare` yourself / in CI. For a **private** root, prefer `postinstall`: Yarn does run it on install, so hooks land automatically (incl. CI) with no manual step and no [pinst](https://github.com/typicode/pinst) guard. Keep `prepare` for **published** packages — an unguarded `postinstall` would run on consumers' installs.
|
|
138
|
+
|
|
139
|
+
`.husky/pre-commit`:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
#!/bin/zsh
|
|
143
|
+
source ~/.zshrc # for VSCode terminal
|
|
144
|
+
yarn lint:staged
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## AI Agent Rules
|
|
148
|
+
|
|
149
|
+
The package also ships a standardized set of coding conventions (`rules/*.md`) and skills for AI coding assistants, wired into a repo by the `lint-prepare` CLI.
|
|
150
|
+
|
|
151
|
+
### Manual Setup (`lint-prepare` CLI) w/o prepare or postinstall
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Initialize (skips if AGENTS.md exists and wasn't generated by this tool)
|
|
155
|
+
lint-prepare init
|
|
156
|
+
|
|
157
|
+
# Force update AGENTS.md
|
|
158
|
+
lint-prepare update
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Customization
|
|
162
|
+
|
|
163
|
+
The generated `AGENTS.md` has a `# Custom Rules` section at the bottom — add project-specific rules there; they're preserved across updates.
|
|
164
|
+
|
|
165
|
+
### How it works
|
|
166
|
+
|
|
167
|
+
In the project root, `lint-prepare`:
|
|
168
|
+
|
|
169
|
+
- Symlinks every `rules/*.md` into `.claude/rules/`, where Claude Code auto-discovers them.
|
|
170
|
+
- Symlinks every skill into `.claude/skills/<name>/` and `.codex/skills/<name>/` (`SKILL.md` plus this `README.md` alongside it, so a skill can reference `@README.md`) — e.g. `lint-repo`, which sets up the tooling above and audits the repo against the rules.
|
|
171
|
+
- Generates `AGENTS.md` referencing the same rules for other assistants (Codex, Cursor, Copilot, …) and symlinks `CLAUDE.md` to it.
|
|
172
|
+
|
|
173
|
+
### Safety checks
|
|
174
|
+
|
|
175
|
+
`init`/`update` refuse to run if `.claude/rules`, a skill target dir, or `CLAUDE.md` contains anything that isn't a symlink — this avoids silently overwriting files you created by hand. If `AGENTS.md` exists and wasn't generated by this tool, `init` skips it; use `update` to force regeneration.
|
|
176
|
+
|
|
177
|
+
### Rule file format
|
|
178
|
+
|
|
179
|
+
```yaml
|
|
180
|
+
---
|
|
181
|
+
type: always_apply # or agent_requested
|
|
182
|
+
description: Set of rules for projects which use Xxx # Required for agent_requested
|
|
183
|
+
paths:
|
|
184
|
+
- '**/*.xxx'
|
|
185
|
+
---
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Why raw JS (no build)
|
|
189
|
+
|
|
190
|
+
Deliberately plain ESM, **no TypeScript build**: the config is loaded by `eslint.config.mjs` and pre-commit `lint:staged` before anything is built, so a `dist/` `main` would force a build before the repo could lint — not worth it for a config package.
|
|
191
|
+
|
|
192
|
+
## Issues
|
|
193
|
+
|
|
194
|
+
- ESLint 9
|
|
195
|
+
- [x] https://github.com/microsoft/rushstack/issues/4635 Failed to patch ESLint because the calling module was not recognized
|
|
196
|
+
- [x] https://github.com/microsoft/rushstack/issues/4965 Failed to patch ESLint because the calling module was not recognized
|
|
197
|
+
- ESLint 10
|
|
198
|
+
- [ ] https://github.com/vercel/next.js/issues/89764 TypeError: Error while loading rule 'react/display-name': contextOrFilename.getFilename is not a function
|
|
199
|
+
- [x] `import/no-default-export` (`eslint-plugin-import@2.32.0`) crashes every lint run under ESLint 10's flat config - its `sourceType()` helper reads `context.parserOptions`, which is `undefined` (not `{}`) there. Worked around by registering `eslint-plugin-import-x` (a drop-in replacement) under its own `import-x` key - see the `eslint-plugin-import-x` block in `index.js` - since ESLint 10 hard-errors ("Cannot redefine plugin") if you try to reuse the `import` key `eslint-config-next` already registers. The enforced rule is therefore `import-x/no-default-export`, not `import/*`.
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
MIT
|