@kitql/eslint-config 0.8.3 → 0.9.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/.oxfmtrc.json +33 -0
- package/.oxlintrc.json +50 -7
- package/README.md +52 -3
- package/cmd.js +98 -69
- package/eslint.config.js +9 -1
- package/package.json +25 -13
- package/src/buildCommands.js +75 -0
package/.oxfmtrc.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
|
3
|
+
"tabWidth": 1,
|
|
4
|
+
"useTabs": true,
|
|
5
|
+
"singleQuote": true,
|
|
6
|
+
"trailingComma": "all",
|
|
7
|
+
"semi": false,
|
|
8
|
+
"arrowParens": "always",
|
|
9
|
+
"printWidth": 100,
|
|
10
|
+
"sortPackageJson": false,
|
|
11
|
+
"sortImports": {
|
|
12
|
+
"groups": [
|
|
13
|
+
"builtin",
|
|
14
|
+
{ "newlinesBetween": false },
|
|
15
|
+
"external",
|
|
16
|
+
"kitql",
|
|
17
|
+
"sveltekit",
|
|
18
|
+
"aliases",
|
|
19
|
+
["parent", "sibling", "index"],
|
|
20
|
+
"unknown"
|
|
21
|
+
],
|
|
22
|
+
"customGroups": [
|
|
23
|
+
{ "groupName": "kitql", "elementNamePattern": ["@kitql/**"] },
|
|
24
|
+
{
|
|
25
|
+
"groupName": "sveltekit",
|
|
26
|
+
"elementNamePattern": ["$env", "$env/**", "$app", "$app/**"]
|
|
27
|
+
},
|
|
28
|
+
{ "groupName": "aliases", "elementNamePattern": ["$*", "$*/**"] }
|
|
29
|
+
],
|
|
30
|
+
"newlinesBetween": true
|
|
31
|
+
},
|
|
32
|
+
"ignorePatterns": []
|
|
33
|
+
}
|
package/.oxlintrc.json
CHANGED
|
@@ -1,19 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
3
3
|
"plugins": ["unicorn", "typescript", "oxc"],
|
|
4
|
-
"jsPlugins": ["eslint-plugin-svelte"],
|
|
4
|
+
"jsPlugins": ["@e18e/eslint-plugin", "eslint-plugin-svelte"],
|
|
5
|
+
"ignorePatterns": ["**/test/fixtures/**"],
|
|
6
|
+
"categories": {
|
|
7
|
+
"correctness": "error"
|
|
8
|
+
},
|
|
5
9
|
"rules": {
|
|
6
|
-
// "no-unused-vars": [
|
|
7
|
-
// "error",
|
|
8
|
-
// { "caughtErrors": "none", "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }
|
|
9
|
-
// ],
|
|
10
10
|
"no-console": [
|
|
11
11
|
"error",
|
|
12
12
|
{
|
|
13
13
|
"allow": ["info", "warn", "error", "time", "timeEnd", "dir"]
|
|
14
14
|
}
|
|
15
15
|
],
|
|
16
|
+
"no-unused-vars": ["error", { "args": "none", "caughtErrors": "none" }],
|
|
17
|
+
"@typescript-eslint/no-unused-vars": ["error", { "args": "none", "caughtErrors": "none" }],
|
|
16
18
|
"@typescript-eslint/no-redundant-type-constituents": "off",
|
|
17
|
-
"no-
|
|
18
|
-
|
|
19
|
+
"@typescript-eslint/no-unused-expressions": "off",
|
|
20
|
+
"no-unused-expressions": "off",
|
|
21
|
+
"no-base-to-string": "off",
|
|
22
|
+
|
|
23
|
+
"e18e/prefer-array-at": "error",
|
|
24
|
+
"e18e/prefer-array-fill": "error",
|
|
25
|
+
"e18e/prefer-includes": "error",
|
|
26
|
+
"e18e/prefer-array-to-reversed": "error",
|
|
27
|
+
"e18e/prefer-array-to-sorted": "error",
|
|
28
|
+
"e18e/prefer-array-to-spliced": "error",
|
|
29
|
+
"e18e/prefer-nullish-coalescing": "error",
|
|
30
|
+
"e18e/prefer-object-has-own": "error",
|
|
31
|
+
"e18e/prefer-spread-syntax": "error",
|
|
32
|
+
"e18e/prefer-url-canparse": "error",
|
|
33
|
+
"e18e/ban-dependencies": "error",
|
|
34
|
+
"e18e/prefer-array-from-map": "error",
|
|
35
|
+
"e18e/prefer-timer-args": "error",
|
|
36
|
+
"e18e/prefer-date-now": "error",
|
|
37
|
+
"e18e/prefer-regex-test": "error",
|
|
38
|
+
"e18e/prefer-array-some": "error",
|
|
39
|
+
"e18e/prefer-static-regex": "error",
|
|
40
|
+
|
|
41
|
+
"@typescript-eslint/prefer-find": "error",
|
|
42
|
+
"@typescript-eslint/prefer-readonly": "error",
|
|
43
|
+
"@typescript-eslint/prefer-regexp-exec": "error"
|
|
44
|
+
},
|
|
45
|
+
"overrides": [
|
|
46
|
+
{
|
|
47
|
+
"files": ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"],
|
|
48
|
+
"rules": {
|
|
49
|
+
"no-var": "error",
|
|
50
|
+
"prefer-const": "error",
|
|
51
|
+
"prefer-rest-params": "error",
|
|
52
|
+
"prefer-spread": "error"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"files": ["**/*.test.ts", "**/*.test.js", "**/*.spec.ts", "**/*.spec.js"],
|
|
57
|
+
"rules": {
|
|
58
|
+
"e18e/prefer-static-regex": "off"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
19
62
|
}
|
package/README.md
CHANGED
|
@@ -13,9 +13,41 @@
|
|
|
13
13
|
npm install @kitql/eslint-config --D
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
### tools
|
|
17
|
+
|
|
18
|
+
`kitql-lint` orchestrates four optional tools - install only what you want to use:
|
|
19
|
+
|
|
20
|
+
| Tool | What it does |
|
|
21
|
+
| --------- | --------------------------------------------------------- |
|
|
22
|
+
| eslint | Linter (svelte rules, pnpm catalog rules, custom rules) |
|
|
23
|
+
| prettier | Formatter (every file type, incl. `.svelte`) |
|
|
24
|
+
| oxlint | Faster linter (Rust); covers most JS/TS rules |
|
|
25
|
+
| oxfmt | Faster formatter (Rust); doesn't speak `.svelte` yet |
|
|
26
|
+
|
|
27
|
+
By default `kitql-lint` runs `eslint` + `prettier`. Pick others with `-t`:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
kitql-lint # eslint + prettier (default)
|
|
31
|
+
kitql-lint -t eslint,prettier,oxlint,tsgolint # add oxlint + type-aware
|
|
32
|
+
kitql-lint -t oxlint,tsgolint,oxfmt,eslint,prettier # 🦀 svelte + full oxc (recommended)
|
|
33
|
+
kitql-lint -t oxlint,tsgolint,oxfmt # 🦀 pure oxc (no .svelte support)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For the svelte combo, enable oxlint integration in eslint to avoid duplicate work on `.ts/.js`:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// eslint.config.js
|
|
40
|
+
import { kitql } from '@kitql/eslint-config'
|
|
41
|
+
|
|
42
|
+
export default [...kitql({ oxlint: { enable: true } })]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
When `oxfmt` is in the tool set, `prettier` auto-restricts to `**/*.svelte` (oxfmt can't parse
|
|
46
|
+
svelte yet); `oxfmt` handles every other file type.
|
|
47
|
+
|
|
16
48
|
### eslint config
|
|
17
49
|
|
|
18
|
-
|
|
50
|
+
`eslint.config.js`
|
|
19
51
|
|
|
20
52
|
```js
|
|
21
53
|
import { kitql } from '@kitql/eslint-config'
|
|
@@ -25,10 +57,10 @@ export default [...kitql()]
|
|
|
25
57
|
|
|
26
58
|
### prettier config
|
|
27
59
|
|
|
28
|
-
`.prettierrc.
|
|
60
|
+
`.prettierrc.js`
|
|
29
61
|
|
|
30
62
|
```js
|
|
31
|
-
import { kitql } from '
|
|
63
|
+
import { kitql } from '@kitql/eslint-config/.prettierrc.js'
|
|
32
64
|
|
|
33
65
|
export default {
|
|
34
66
|
...kitql(),
|
|
@@ -36,6 +68,23 @@ export default {
|
|
|
36
68
|
}
|
|
37
69
|
```
|
|
38
70
|
|
|
71
|
+
### oxlint config
|
|
72
|
+
|
|
73
|
+
`.oxlintrc.json`
|
|
74
|
+
|
|
75
|
+
```jsonc
|
|
76
|
+
{
|
|
77
|
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
78
|
+
"extends": ["./node_modules/@kitql/eslint-config/.oxlintrc.json"],
|
|
79
|
+
"rules": {}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### oxfmt config
|
|
84
|
+
|
|
85
|
+
`.oxfmtrc.json` - copy from
|
|
86
|
+
[`@kitql/eslint-config/.oxfmtrc.json`](./.oxfmtrc.json) (oxfmt has no `extends` yet).
|
|
87
|
+
|
|
39
88
|
### ignore things with
|
|
40
89
|
|
|
41
90
|
`.prettierignore`
|
package/cmd.js
CHANGED
|
@@ -2,46 +2,78 @@
|
|
|
2
2
|
import { spawn } from 'node:child_process'
|
|
3
3
|
import fs from 'node:fs'
|
|
4
4
|
import path from 'node:path'
|
|
5
|
-
import { Option, program } from 'commander'
|
|
6
5
|
|
|
7
6
|
import { gray, green, Log } from '@kitql/helpers'
|
|
7
|
+
import { parseCli } from '@kitql/helpers/server'
|
|
8
8
|
|
|
9
9
|
import { findFileOrUp } from './helper/findFileOrUp.js'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
10
|
+
import {
|
|
11
|
+
buildEslintCmd,
|
|
12
|
+
buildOxfmtCmd,
|
|
13
|
+
buildOxlintCmd,
|
|
14
|
+
buildPrettierCmd,
|
|
15
|
+
} from './src/buildCommands.js'
|
|
16
|
+
|
|
17
|
+
/** @type {('eslint' | 'prettier' | 'oxlint' | 'tsgolint' | 'oxfmt')[]} */
|
|
18
|
+
const TOOLS_ALL = ['eslint', 'prettier', 'oxlint', 'tsgolint', 'oxfmt']
|
|
19
|
+
const TOOLS_DEFAULT = ['eslint', 'prettier']
|
|
20
|
+
|
|
21
|
+
const { values: options_cli, help } = parseCli({
|
|
22
|
+
name: 'kitql-lint',
|
|
23
|
+
options: {
|
|
24
|
+
format: { type: 'boolean', short: 'f', description: 'format' },
|
|
25
|
+
glob: { type: 'string', short: 'g', default: '.', description: 'file/dir/glob' },
|
|
26
|
+
tools: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
short: 't',
|
|
29
|
+
default: TOOLS_DEFAULT.join(','),
|
|
30
|
+
description: 'tools to use (eslint, prettier, oxlint, tsgolint, oxfmt)',
|
|
31
|
+
},
|
|
32
|
+
verbose: { type: 'boolean', short: 'v', default: false, description: 'add more logs' },
|
|
33
|
+
'diff-only': {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
short: 'd',
|
|
36
|
+
default: false,
|
|
37
|
+
description: 'only check files changed against base branch',
|
|
38
|
+
},
|
|
39
|
+
'base-branch': {
|
|
40
|
+
type: 'string',
|
|
41
|
+
short: 'b',
|
|
42
|
+
default: 'main',
|
|
43
|
+
description: 'base branch to compare against',
|
|
44
|
+
},
|
|
45
|
+
prefix: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
short: 'p',
|
|
48
|
+
default: 'none',
|
|
49
|
+
description: 'prefix by with "pnpm" or "npm" or "none"',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
if (options_cli.help) {
|
|
55
|
+
console.info(help)
|
|
56
|
+
process.exit(0)
|
|
57
|
+
}
|
|
34
58
|
|
|
35
59
|
const pathPrettierIgnore = findFileOrUp('.prettierignore')
|
|
36
60
|
const pathPrettier_js = findFileOrUp('.prettierrc.js')
|
|
61
|
+
const pathOxfmtrc = findFileOrUp('.oxfmtrc.json')
|
|
37
62
|
|
|
38
63
|
const format = /** @type {boolean} */ (options_cli.format ?? false)
|
|
39
64
|
let glob = /** @type {string} */ (options_cli.glob ?? '.')
|
|
40
65
|
const verbose = /** @type {boolean} */ (options_cli.verbose ?? false)
|
|
41
66
|
const pre = /** @type {string} */ (options_cli.prefix ?? 'none')
|
|
42
|
-
const tools = /** @type {typeof TOOLS_ALL} */ (
|
|
43
|
-
|
|
44
|
-
|
|
67
|
+
const tools = /** @type {typeof TOOLS_ALL} */ (
|
|
68
|
+
String(options_cli.tools ?? TOOLS_DEFAULT.join(',')).split(',')
|
|
69
|
+
)
|
|
70
|
+
const unknown = tools.filter((t) => !TOOLS_ALL.includes(t))
|
|
71
|
+
if (unknown.length > 0) {
|
|
72
|
+
console.error(`Unknown tool(s): ${unknown.join(', ')}. Supported: ${TOOLS_ALL.join(', ')}`)
|
|
73
|
+
process.exit(2)
|
|
74
|
+
}
|
|
75
|
+
const diffOnly = /** @type {boolean} */ (options_cli['diff-only'] ?? false)
|
|
76
|
+
const baseBranch = /** @type {string} */ (options_cli['base-branch'] ?? 'main')
|
|
45
77
|
|
|
46
78
|
const log = new Log('kitql-lint')
|
|
47
79
|
// const spinner = new Spinner({ symbolFormatter: (msg) => bgBlueBright(` kitql-lint `) + ' ' + msg })
|
|
@@ -269,55 +301,41 @@ async function getDiffFiles() {
|
|
|
269
301
|
}
|
|
270
302
|
}
|
|
271
303
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
304
|
+
function buildOpts() {
|
|
305
|
+
return {
|
|
306
|
+
tools,
|
|
307
|
+
format,
|
|
308
|
+
glob,
|
|
309
|
+
pre: preToUse,
|
|
310
|
+
pathPrettierIgnore,
|
|
311
|
+
pathPrettier_js,
|
|
312
|
+
pathOxfmtrc,
|
|
313
|
+
}
|
|
314
|
+
}
|
|
279
315
|
|
|
316
|
+
async function runOxc(/** @type {string} */ name) {
|
|
317
|
+
const cmdLint = buildOxlintCmd(buildOpts())
|
|
280
318
|
log.info(gray(`${verbose ? cmdLint : name} `))
|
|
281
|
-
|
|
282
|
-
const result_lint = await customSpawn(cmdLint)
|
|
283
|
-
|
|
284
|
-
return result_lint
|
|
319
|
+
return customSpawn(cmdLint)
|
|
285
320
|
}
|
|
286
321
|
|
|
287
322
|
async function runEslint() {
|
|
288
|
-
const cmd =
|
|
289
|
-
preToUse +
|
|
290
|
-
`eslint --no-warn-ignored` +
|
|
291
|
-
// format or not
|
|
292
|
-
`${format ? ' --fix' : ''}` +
|
|
293
|
-
// exec
|
|
294
|
-
` ${glob}`
|
|
295
|
-
|
|
323
|
+
const cmd = buildEslintCmd(buildOpts())
|
|
296
324
|
log.info(gray(`${verbose ? cmd : 'eslint'} `))
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
return result_lint
|
|
325
|
+
return customSpawn(cmd)
|
|
300
326
|
}
|
|
301
327
|
|
|
302
328
|
async function runPrettier() {
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
// exec
|
|
314
|
-
` ${glob}`
|
|
315
|
-
|
|
316
|
-
log.info(gray(`${verbose ? cmdFormat : 'prettier'} `))
|
|
317
|
-
|
|
318
|
-
const result_format = await customSpawn(cmdFormat)
|
|
319
|
-
|
|
320
|
-
return result_format
|
|
329
|
+
const cmd = buildPrettierCmd(buildOpts())
|
|
330
|
+
const svelteOnly = tools.includes('oxfmt')
|
|
331
|
+
log.info(gray(`${verbose ? cmd : svelteOnly ? 'prettier (svelte)' : 'prettier'} `))
|
|
332
|
+
return customSpawn(cmd)
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
async function runOxfmt() {
|
|
336
|
+
const cmd = buildOxfmtCmd(buildOpts())
|
|
337
|
+
log.info(gray(`${verbose ? cmd : 'oxfmt'} `))
|
|
338
|
+
return customSpawn(cmd)
|
|
321
339
|
}
|
|
322
340
|
|
|
323
341
|
/** @type {string[]} */
|
|
@@ -370,11 +388,22 @@ if (tools.includes('eslint') && glob) {
|
|
|
370
388
|
}
|
|
371
389
|
}
|
|
372
390
|
|
|
391
|
+
if (tools.includes('oxfmt') && glob) {
|
|
392
|
+
const start = performance.now()
|
|
393
|
+
const code = await runOxfmt()
|
|
394
|
+
const stepTook = performance.now() - start
|
|
395
|
+
took.push(display('oxfmt', stepTook))
|
|
396
|
+
if (typeof code === 'object' && 'status' in code && code.status) {
|
|
397
|
+
log.error(`format failed, check logs above. ${displayTook()}`)
|
|
398
|
+
process.exit(Number(code.status))
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
373
402
|
if (tools.includes('prettier') && glob) {
|
|
374
403
|
const start = performance.now()
|
|
375
404
|
const code = await runPrettier()
|
|
376
405
|
const stepTook = performance.now() - start
|
|
377
|
-
took.push(display('prettier', stepTook))
|
|
406
|
+
took.push(display(tools.includes('oxfmt') ? 'prettier (svelte)' : 'prettier', stepTook))
|
|
378
407
|
if (typeof code === 'object' && 'status' in code && code.status) {
|
|
379
408
|
log.error(`format failed, check logs above. ${displayTook()}`)
|
|
380
409
|
process.exit(Number(code.status))
|
package/eslint.config.js
CHANGED
|
@@ -119,7 +119,15 @@ const othersRules = ({ svelteConfig } = {}) => {
|
|
|
119
119
|
},
|
|
120
120
|
{
|
|
121
121
|
name: '@kitql:ignores',
|
|
122
|
-
ignores: [
|
|
122
|
+
ignores: [
|
|
123
|
+
'build/',
|
|
124
|
+
'.svelte-kit/',
|
|
125
|
+
'dist/',
|
|
126
|
+
'**/build/',
|
|
127
|
+
'**/.svelte-kit/',
|
|
128
|
+
'**/dist/',
|
|
129
|
+
'**/test/fixtures/**',
|
|
130
|
+
],
|
|
123
131
|
},
|
|
124
132
|
{
|
|
125
133
|
name: '@kitql:tests',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitql/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "opinionated linting and formatting for projects",
|
|
6
6
|
"repository": {
|
|
@@ -18,12 +18,14 @@
|
|
|
18
18
|
"main": "eslint.config.js",
|
|
19
19
|
"types": "eslint.config.d.ts",
|
|
20
20
|
"files": [
|
|
21
|
+
".oxfmtrc.json",
|
|
21
22
|
".oxlintrc.json",
|
|
22
23
|
".prettierrc.js",
|
|
23
24
|
"cmd.js",
|
|
24
25
|
"eslint.config.js",
|
|
25
26
|
"eslint.config.d.ts",
|
|
26
|
-
"helper/findFileOrUp.js"
|
|
27
|
+
"helper/findFileOrUp.js",
|
|
28
|
+
"src/buildCommands.js"
|
|
27
29
|
],
|
|
28
30
|
"keywords": [
|
|
29
31
|
"cli",
|
|
@@ -34,15 +36,19 @@
|
|
|
34
36
|
"format"
|
|
35
37
|
],
|
|
36
38
|
"peerDependencies": {
|
|
37
|
-
"eslint": "10.
|
|
38
|
-
"
|
|
39
|
-
"oxlint
|
|
40
|
-
"
|
|
39
|
+
"eslint": "10.4.0",
|
|
40
|
+
"oxfmt": "0.51.0",
|
|
41
|
+
"oxlint": "1.66.0",
|
|
42
|
+
"oxlint-tsgolint": "0.23.0",
|
|
43
|
+
"prettier": "^3.8.3"
|
|
41
44
|
},
|
|
42
45
|
"peerDependenciesMeta": {
|
|
43
46
|
"eslint": {
|
|
44
47
|
"optional": true
|
|
45
48
|
},
|
|
49
|
+
"oxfmt": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
46
52
|
"oxlint": {
|
|
47
53
|
"optional": true
|
|
48
54
|
},
|
|
@@ -53,26 +59,29 @@
|
|
|
53
59
|
"optional": true
|
|
54
60
|
}
|
|
55
61
|
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@vitest/coverage-v8": "4.1.4",
|
|
64
|
+
"vitest": "4.1.4"
|
|
65
|
+
},
|
|
56
66
|
"dependencies": {
|
|
57
|
-
"@e18e/eslint-plugin": "^0.
|
|
67
|
+
"@e18e/eslint-plugin": "^0.5.0",
|
|
58
68
|
"@eslint/compat": "2.1.0",
|
|
59
69
|
"@eslint/js": "10.0.1",
|
|
60
70
|
"@ianvs/prettier-plugin-sort-imports": "^4.7.0",
|
|
61
71
|
"@types/eslint": "9.6.1",
|
|
62
72
|
"@typescript-eslint/parser": "8.59.3",
|
|
63
|
-
"commander": "14.0.0",
|
|
64
73
|
"eslint-config-prettier": "10.1.5",
|
|
65
|
-
"eslint-plugin-oxlint": "1.
|
|
74
|
+
"eslint-plugin-oxlint": "1.66.0",
|
|
66
75
|
"eslint-plugin-pnpm": "1.6.0",
|
|
67
76
|
"eslint-plugin-svelte": "3.17.1",
|
|
68
77
|
"globals": "17.6.0",
|
|
69
78
|
"jsonc-eslint-parser": "3.1.0",
|
|
70
79
|
"prettier-plugin-sh": "^0.18.0",
|
|
71
|
-
"prettier-plugin-svelte": "^
|
|
72
|
-
"prettier-plugin-tailwindcss": "^0.
|
|
80
|
+
"prettier-plugin-svelte": "^4.0.0",
|
|
81
|
+
"prettier-plugin-tailwindcss": "^0.8.0",
|
|
73
82
|
"typescript-eslint": "8.59.3",
|
|
74
83
|
"yaml-eslint-parser": "2.0.0",
|
|
75
|
-
"@kitql/helpers": "0.8.
|
|
84
|
+
"@kitql/helpers": "0.8.15"
|
|
76
85
|
},
|
|
77
86
|
"publishConfig": {
|
|
78
87
|
"access": "public"
|
|
@@ -83,6 +92,9 @@
|
|
|
83
92
|
"format:example": "kitql-lint --format",
|
|
84
93
|
"inspector": "npx @eslint/config-inspector",
|
|
85
94
|
"lint": "node ./cmd.js --verbose -p none",
|
|
86
|
-
"lint:
|
|
95
|
+
"lint:oxc": "node ./cmd.js -p none -t oxlint,oxfmt,prettier",
|
|
96
|
+
"lint:example": "kitql-lint",
|
|
97
|
+
"test": "vitest",
|
|
98
|
+
"test:ci": "vitest run --coverage"
|
|
87
99
|
}
|
|
88
100
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers that build the shell commands `kitql-lint` runs.
|
|
3
|
+
* Extracted so they can be unit-tested without spawning processes.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} BuildOptions
|
|
8
|
+
* @property {string[]} tools - selected tools
|
|
9
|
+
* @property {boolean} format - format vs lint
|
|
10
|
+
* @property {string} glob - target glob/files
|
|
11
|
+
* @property {string} [pre] - prefix to prepend to commands ('', 'pnpm ', 'npm exec ')
|
|
12
|
+
* @property {string} [pathPrettierIgnore]
|
|
13
|
+
* @property {string} [pathPrettier_js]
|
|
14
|
+
* @property {string} [pathOxfmtrc]
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {BuildOptions} opts
|
|
19
|
+
*/
|
|
20
|
+
export function buildOxlintCmd(opts) {
|
|
21
|
+
const { tools, format, glob, pre = '' } = opts
|
|
22
|
+
return (
|
|
23
|
+
pre +
|
|
24
|
+
`oxlint` +
|
|
25
|
+
`${tools.includes('tsgolint') ? ' --type-aware' : ''}` +
|
|
26
|
+
`${format ? ' --fix' : ''}` +
|
|
27
|
+
` ${glob}`
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {BuildOptions} opts
|
|
33
|
+
*/
|
|
34
|
+
export function buildEslintCmd(opts) {
|
|
35
|
+
const { format, glob, pre = '' } = opts
|
|
36
|
+
return pre + `eslint --no-warn-ignored` + `${format ? ' --fix' : ''}` + ` ${glob}`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {BuildOptions} opts
|
|
41
|
+
*/
|
|
42
|
+
export function buildPrettierCmd(opts) {
|
|
43
|
+
const { tools, format, glob, pre = '', pathPrettierIgnore, pathPrettier_js } = opts
|
|
44
|
+
// When oxfmt is in the tool set, oxfmt formats every file type it supports
|
|
45
|
+
// and prettier only handles .svelte (oxfmt can't parse it yet) - regardless of mode.
|
|
46
|
+
const svelteOnly = tools.includes('oxfmt')
|
|
47
|
+
const target = svelteOnly ? `'**/*.svelte'` : glob
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
pre +
|
|
51
|
+
`prettier` +
|
|
52
|
+
` --list-different` +
|
|
53
|
+
` --ignore-path ${pathPrettierIgnore}` +
|
|
54
|
+
` --config ${pathPrettier_js}` +
|
|
55
|
+
`${svelteOnly ? ' --no-error-on-unmatched-pattern' : ''}` +
|
|
56
|
+
`${format ? ' --write' : ''}` +
|
|
57
|
+
` ${target}`
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {BuildOptions} opts
|
|
63
|
+
*/
|
|
64
|
+
export function buildOxfmtCmd(opts) {
|
|
65
|
+
const { format, glob, pre = '', pathPrettierIgnore, pathOxfmtrc } = opts
|
|
66
|
+
return (
|
|
67
|
+
pre +
|
|
68
|
+
`oxfmt` +
|
|
69
|
+
(pathPrettierIgnore ? ` --ignore-path ${pathPrettierIgnore}` : '') +
|
|
70
|
+
(pathOxfmtrc ? ` --config ${pathOxfmtrc}` : '') +
|
|
71
|
+
`${format ? ' --write' : ' --check'}` +
|
|
72
|
+
` --no-error-on-unmatched-pattern` +
|
|
73
|
+
` ${glob}`
|
|
74
|
+
)
|
|
75
|
+
}
|