@kitql/eslint-config 0.8.0-next.2 → 0.8.0-next.3

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/.prettierrc.js CHANGED
@@ -1,14 +1,14 @@
1
- import prettierConfig from '@theguild/prettier-config'
2
-
3
1
  const config = {
4
- ...prettierConfig,
5
2
  tabWidth: 1,
6
3
  useTabs: true,
7
4
  singleQuote: true,
5
+ trailingComma: 'all',
8
6
  semi: false,
9
7
  arrowParens: 'always',
8
+ printWidth: 100,
10
9
  plugins: [
11
- ...prettierConfig.plugins,
10
+ '@ianvs/prettier-plugin-sort-imports',
11
+ 'prettier-plugin-sh',
12
12
  'prettier-plugin-svelte',
13
13
  'prettier-plugin-tailwindcss', // MUST come last
14
14
  ],
@@ -31,15 +31,15 @@ const config = {
31
31
  '',
32
32
  '^[./]', // inside
33
33
  ],
34
- overrides: [
35
- {
36
- files: ['README.md', 'packages/**/README.md'],
37
- options: {
38
- useTabs: false,
39
- tabWidth: 2,
40
- },
41
- },
42
- ],
34
+ // overrides: [
35
+ // {
36
+ // files: ['README.md', 'packages/**/README.md'],
37
+ // options: {
38
+ // useTabs: false,
39
+ // tabWidth: 2,
40
+ // },
41
+ // },
42
+ // ],
43
43
  }
44
44
  export default config
45
45
 
package/cmd.js CHANGED
@@ -9,7 +9,10 @@ import { bgBlueBright, bgGreen, bgRedBright, gray, green, red } from '@kitql/hel
9
9
 
10
10
  import { findFileOrUp } from './helper/findFileOrUp.js'
11
11
 
12
- // df
12
+ /** @type {('eslint' | 'prettier' | 'oxlint' | 'tsgolint')[]} */
13
+ const TOOLS_ALL = ['eslint', 'prettier', 'oxlint', 'tsgolint']
14
+ const TOOLS_DEFAULT = TOOLS_ALL.slice(0, 2)
15
+
13
16
  const spinner = ora({
14
17
  // hideCursor: true,
15
18
  prefixText: bgBlueBright(` kitql-lint `),
@@ -18,25 +21,21 @@ const spinner = ora({
18
21
  spinner.start()
19
22
 
20
23
  program.addOption(new Option('-f, --format', 'format'))
21
- program.addOption(new Option('-g, --glob <type>', 'file/dir/glob (. by default)').default('.'))
22
- program.addOption(new Option('--lint-only', 'only run lint').default(false))
23
- program.addOption(new Option('--format-only', 'only run format').default(false))
24
- program.addOption(new Option('--verbose', 'add more logs').default(false))
25
- program.addOption(new Option('--ox', 'using oxc tooling').default(false))
26
- program.addOption(new Option('--oxt', 'using oxc & type aware').default(false))
24
+ program.addOption(new Option('-g, --glob <type>', 'file/dir/glob').default('.'))
25
+ program.addOption(
26
+ new Option('-t, --tools <type>', 'tools to use (eslint, prettier, oxlint, tsgolint)').default(
27
+ TOOLS_DEFAULT.join(','),
28
+ ),
29
+ )
30
+ program.addOption(new Option('-v, --verbose', 'add more logs').default(false))
27
31
  program.addOption(
28
32
  new Option('-d, --diff-only', 'only check files changed against base branch').default(false),
29
33
  )
30
34
  program.addOption(
31
- new Option('--base-branch <type>', 'base branch to compare against (default: main)').default(
32
- 'main',
33
- ),
35
+ new Option('-b, --base-branch <type>', 'base branch to compare against').default('main'),
34
36
  )
35
37
  program.addOption(
36
- new Option(
37
- '-p, --prefix <type>',
38
- 'prefix by with "pnpm" or "npm" or "none" ("none" by default)',
39
- ).default('none'),
38
+ new Option('-p, --prefix <type>', 'prefix by with "pnpm" or "npm" or "none"').default('none'),
40
39
  )
41
40
  program.parse(process.argv)
42
41
  const options_cli = program.opts()
@@ -44,16 +43,13 @@ const options_cli = program.opts()
44
43
  const pathPrettierIgnore = findFileOrUp('.prettierignore')
45
44
  const pathPrettier_js = findFileOrUp('.prettierrc.js')
46
45
 
47
- const format = options_cli.format ?? false
48
- let glob = options_cli.glob ?? '.'
49
- const verbose = options_cli.verbose ?? false
50
- const pre = options_cli.prefix ?? 'none'
51
- const lintOnly = options_cli.lintOnly ?? false
52
- const formatOnly = options_cli.formatOnly ?? false
53
- const diffOnly = options_cli.diffOnly ?? false
54
- const baseBranch = options_cli.baseBranch ?? 'main'
55
- const using_ox = options_cli.ox ?? false
56
- const using_oxt = options_cli.oxt ?? false
46
+ const format = /** @type {boolean} */ (options_cli.format ?? false)
47
+ let glob = /** @type {string} */ (options_cli.glob ?? '.')
48
+ const verbose = /** @type {boolean} */ (options_cli.verbose ?? false)
49
+ const pre = /** @type {string} */ (options_cli.prefix ?? 'none')
50
+ const tools = /** @type {typeof TOOLS_ALL} */ (options_cli.tools.split(',') ?? TOOLS_DEFAULT)
51
+ const diffOnly = /** @type {boolean} */ (options_cli.diffOnly ?? false)
52
+ const baseBranch = /** @type {string} */ (options_cli.baseBranch ?? 'main')
57
53
 
58
54
  let preToUse = ''
59
55
  if (pre === 'npm') {
@@ -278,12 +274,12 @@ async function getDiffFiles() {
278
274
  async function lintRunOx() {
279
275
  const cmdLint =
280
276
  `oxlint` +
281
- `${using_oxt ? ' --type-aware' : ''}` +
277
+ `${tools.includes('tsgolint') ? ' --type-aware' : ''}` +
282
278
  // format or not
283
279
  `${format ? ' --fix' : ''}` +
284
280
  ` ${glob}`
285
281
 
286
- spinner.text = verbose ? 'lint ' + gray(`(${cmdLint}) `) : 'lint '
282
+ spinner.text = 'linting ' + gray(`(${verbose ? cmdLint : 'oxc'}) `)
287
283
 
288
284
  const result_lint = await customSpawn(cmdLint)
289
285
 
@@ -291,26 +287,30 @@ async function lintRunOx() {
291
287
  }
292
288
 
293
289
  async function lintRun() {
294
- if (using_ox || using_oxt) {
290
+ if (tools.includes('oxlint')) {
295
291
  const result_lint = await lintRunOx()
296
292
  if (typeof result_lint === 'object' && 'status' in result_lint && result_lint.status) {
297
293
  return result_lint
298
294
  }
299
295
  }
300
296
 
301
- const cmdLint =
302
- preToUse +
303
- `eslint --no-warn-ignored` +
304
- // format or not
305
- `${format ? ' --fix' : ''}` +
306
- // exec
307
- ` ${glob}`
297
+ if (tools.includes('eslint')) {
298
+ const cmdLint =
299
+ preToUse +
300
+ `eslint --no-warn-ignored` +
301
+ // format or not
302
+ `${format ? ' --fix' : ''}` +
303
+ // exec
304
+ ` ${glob}`
308
305
 
309
- spinner.text = verbose ? 'lint ' + gray(`(${cmdLint}) `) : 'lint '
306
+ spinner.text = 'linting ' + gray(`(${verbose ? cmdLint : 'eslint'}) `)
310
307
 
311
- const result_lint = await customSpawn(cmdLint)
308
+ const result_lint = await customSpawn(cmdLint)
312
309
 
313
- return result_lint
310
+ return result_lint
311
+ }
312
+
313
+ return ''
314
314
  }
315
315
 
316
316
  async function formatRun() {
@@ -327,7 +327,7 @@ async function formatRun() {
327
327
  // exec
328
328
  ` ${glob}`
329
329
 
330
- spinner.text = verbose ? 'format ' + gray(`(${cmdFormat}) `) : 'format '
330
+ spinner.text = 'formating ' + gray(`(${verbose ? cmdFormat : 'prettier'}) `)
331
331
 
332
332
  const result_format = await customSpawn(cmdFormat)
333
333
 
@@ -361,7 +361,7 @@ if (diffOnly) {
361
361
  }
362
362
  }
363
363
 
364
- if (!formatOnly && glob) {
364
+ if ((tools.includes('eslint') || tools.includes('oxlint')) && glob) {
365
365
  const lintStart = performance.now()
366
366
  const lintCode = await lintRun()
367
367
  const lintTook = performance.now() - lintStart
@@ -373,7 +373,7 @@ if (!formatOnly && glob) {
373
373
  }
374
374
  }
375
375
 
376
- if (!lintOnly && glob) {
376
+ if (tools.includes('prettier') && glob) {
377
377
  const formatStart = performance.now()
378
378
  const formatCode = await formatRun()
379
379
  const formatTook = performance.now() - formatStart
package/eslint.config.js CHANGED
@@ -173,9 +173,15 @@ const othersRules = () => {
173
173
  ]
174
174
  }
175
175
 
176
+ /**
177
+ * @typedef {Object} OxlintConfig
178
+ * @property {boolean} [enable] - Whether to enable oxlint
179
+ */
180
+
176
181
  /**
177
182
  * @typedef {Object} KitqlOptions
178
183
  * @property {PnpmCatalogsConfig} [pnpmCatalogs] - Configuration object for pnpm catalogs
184
+ * @property {OxlintConfig} [oxlint] - Configuration object for oxlint
179
185
  */
180
186
 
181
187
  /**
@@ -186,18 +192,27 @@ export const kitql = (options = {}) => {
186
192
  const pnpmCatalogsConfig = options?.pnpmCatalogs ?? { enable: false }
187
193
  const pnpmCatalogsEnabled = pnpmCatalogsConfig.enable !== false
188
194
 
189
- const pathOxlintrc = findFileOrUp('.oxlintrc.json') ?? './.oxlintrc.json'
190
-
191
- return [
192
- //
195
+ const arr = [
196
+ // default rules
193
197
  rulePrettierIgnore({ pnpmCatalogsEnabled }),
194
198
  ...othersRules(),
195
- ...(pnpmCatalogsEnabled ? rulePnpmCatalogs(pnpmCatalogsConfig) : []),
196
- ...oxlint.buildFromOxlintConfigFile(pathOxlintrc),
197
199
  ]
200
+
201
+ if (pnpmCatalogsEnabled) {
202
+ arr.push(...rulePnpmCatalogs(pnpmCatalogsConfig))
203
+ }
204
+
205
+ const oxlintConfig = options?.oxlint ?? { enable: false }
206
+ const oxlintEnabled = oxlintConfig.enable !== false
207
+ if (oxlintEnabled) {
208
+ const pathOxlintrc = findFileOrUp('.oxlintrc.json') ?? './.oxlintrc.json'
209
+ arr.push(...oxlint.buildFromOxlintConfigFile(pathOxlintrc))
210
+ }
211
+
212
+ return arr
198
213
  }
199
214
 
200
215
  /** @type {import('eslint').Linter.Config[]} */
201
- const config = kitql({ pnpmCatalogs: { enable: true } })
216
+ const config = kitql()
202
217
 
203
218
  export default config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitql/eslint-config",
3
- "version": "0.8.0-next.2",
3
+ "version": "0.8.0-next.3",
4
4
  "type": "module",
5
5
  "description": "opinionated linting and formatting for projects",
6
6
  "repository": {
@@ -26,9 +26,13 @@
26
26
  "keywords": [
27
27
  "cli",
28
28
  "eslint",
29
- "eslint-config"
29
+ "eslint-config",
30
+ "oxc",
31
+ "lint",
32
+ "format"
30
33
  ],
31
34
  "peerDependencies": {
35
+ "eslint": "9.37.0",
32
36
  "oxlint": "1.23.0",
33
37
  "oxlint-tsgolint": "0.2.0",
34
38
  "prettier": "^3.6.1"
@@ -44,11 +48,10 @@
44
48
  "dependencies": {
45
49
  "@eslint/compat": "1.4.0",
46
50
  "@eslint/js": "9.37.0",
47
- "@theguild/prettier-config": "3.0.0",
51
+ "@ianvs/prettier-plugin-sort-imports": "^4.7.0",
48
52
  "@types/eslint": "9.6.1",
49
53
  "@typescript-eslint/parser": "8.46.1",
50
54
  "commander": "14.0.0",
51
- "eslint": "9.37.0",
52
55
  "eslint-config-prettier": "10.1.5",
53
56
  "eslint-plugin-oxlint": "1.23.0",
54
57
  "eslint-plugin-pnpm": "1.2.0",
@@ -57,6 +60,7 @@
57
60
  "globals": "16.4.0",
58
61
  "jsonc-eslint-parser": "2.4.0",
59
62
  "ora": "9.0.0",
63
+ "prettier-plugin-sh": "^0.18.0",
60
64
  "prettier-plugin-svelte": "3.4.0",
61
65
  "prettier-plugin-tailwindcss": "0.7.0",
62
66
  "typescript-eslint": "8.46.1",
@@ -68,10 +72,10 @@
68
72
  },
69
73
  "sideEffects": false,
70
74
  "scripts": {
71
- "format": "node ./cmd.js -f -d --verbose --oxt",
75
+ "format": "node ./cmd.js -f -d --verbose",
72
76
  "format:example": "kitql-lint --format",
73
77
  "inspector": "npx @eslint/config-inspector",
74
- "lint": "node ./cmd.js --verbose -p none --oxt",
78
+ "lint": "node ./cmd.js --verbose -p none",
75
79
  "lint:example": "kitql-lint"
76
80
  }
77
81
  }