@kitql/eslint-config 0.5.6 → 0.5.8

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/cmd.js CHANGED
@@ -312,6 +312,7 @@ const took = []
312
312
  const display = (text, time) => {
313
313
  return `${gray(text)} ${green((time / 1000).toFixed(3))}${gray('s')}`
314
314
  }
315
+ const displayTook = () => `${gray('(')}${took.join(gray(', '))}${gray(')')}`
315
316
 
316
317
  // If changed-only flag is set, get the list of changed files
317
318
  if (diffOnly) {
@@ -335,7 +336,7 @@ if (!prettierOnly && glob) {
335
336
  took.push(display('eslint', esLintTook))
336
337
  if (eslintCode.status) {
337
338
  spinner.prefixText = bgRedBright(` kitql-lint `)
338
- spinner.fail(red(`eslint failed, check logs above.`))
339
+ spinner.fail(red(`eslint failed, check logs above. ${displayTook()}`))
339
340
  process.exit(eslintCode.status)
340
341
  }
341
342
  }
@@ -347,14 +348,22 @@ if (!eslintOnly && glob) {
347
348
  took.push(display('prettier', prettierTook))
348
349
  if (prettierCode.status) {
349
350
  spinner.prefixText = bgRedBright(` kitql-lint `)
350
- spinner.fail(red(`prettier failed, check logs above.`))
351
+ spinner.fail(red(`prettier failed, check logs above. ${displayTook()}`))
351
352
  process.exit(prettierCode.status)
352
353
  }
353
354
  }
354
355
 
355
356
  spinner.prefixText = bgGreen(` kitql-lint `)
356
357
  spinner.succeed(
357
- `All good, ${glob === '' ? 'nothing to do!' : filesLength !== -1 ? `your ${filesLength} files looks great!` : 'your files looks great!'} ${gray('(')}${took.join(gray(', '))}${gray(')')}`,
358
+ `All good, ` +
359
+ `${
360
+ glob === ''
361
+ ? 'nothing to do!'
362
+ : filesLength !== -1
363
+ ? `your ${filesLength === 1 ? 'single file' : `${filesLength} files`} looks great!`
364
+ : 'your files looks great!'
365
+ } ` +
366
+ displayTook(),
358
367
  )
359
368
  spinner.stop()
360
369
  process.exit(0)
package/eslint.config.js CHANGED
@@ -9,30 +9,50 @@ import ts from 'typescript-eslint'
9
9
 
10
10
  import { findFileOrUp } from './helper/findFileOrUp.js'
11
11
 
12
- const rulePrettierIgnore = ({ pnpmCatalogs = true }) => {
12
+ /**
13
+ * @typedef {Object} PnpmCatalogsConfig
14
+ * @property {boolean} [enable=true] - Whether to enable pnpm catalogs rules
15
+ * @property {string[]} [files] - Files to apply the rules to
16
+ * @property {Record<string, string>} [rules] - Rules configuration
17
+ */
18
+
19
+ const rulePrettierIgnore = ({ pnpmCatalogsEnabled = true }) => {
13
20
  const pathPrettierIgnore = findFileOrUp('.prettierignore', { absolute: true })
14
- const rowIgnore = pathPrettierIgnore ? includeIgnoreFile(pathPrettierIgnore).ignores : []
15
- const ignores = pnpmCatalogs ? rowIgnore.filter((c) => !c.includes('package.json')) : rowIgnore
21
+ const rowIgnore = pathPrettierIgnore ? (includeIgnoreFile(pathPrettierIgnore).ignores ?? []) : []
22
+ const ignores = pnpmCatalogsEnabled
23
+ ? rowIgnore.filter((c) => !c.includes('package.json'))
24
+ : rowIgnore
16
25
  return {
17
26
  name: '@kitql:prettier:ignores',
18
27
  ignores,
19
28
  }
20
29
  }
21
30
 
22
- const rulePnpmCatalogs = () => {
31
+ /**
32
+ * @param {PnpmCatalogsConfig} options
33
+ */
34
+ const rulePnpmCatalogs = (options = {}) => {
35
+ const {
36
+ enable = true,
37
+ files = ['package.json', '**/package.json'],
38
+ rules = {
39
+ 'pnpm-catalogs/enforce-catalog': 'error',
40
+ 'pnpm-catalogs/valid-catalog': 'error',
41
+ },
42
+ } = options
43
+
44
+ if (!enable) return null
45
+
23
46
  return {
24
47
  name: 'pnpm-catalogs:package.json',
25
- files: ['package.json'],
48
+ files,
26
49
  languageOptions: {
27
50
  parser: jsoncParser,
28
51
  },
29
52
  plugins: {
30
53
  'pnpm-catalogs': pnpmCatalogs,
31
54
  },
32
- rules: {
33
- 'pnpm-catalogs/enforce-catalog': 'error',
34
- 'pnpm-catalogs/valid-catalog': 'error',
35
- },
55
+ rules,
36
56
  }
37
57
  }
38
58
 
@@ -122,7 +142,7 @@ const othersRules = () => {
122
142
  /** @type {import('eslint').Linter.Config[]} */
123
143
  const config = [
124
144
  //
125
- rulePrettierIgnore({ pnpmCatalogs: true }),
145
+ rulePrettierIgnore({ pnpmCatalogsEnabled: true }),
126
146
  ...othersRules(),
127
147
  rulePnpmCatalogs(),
128
148
  ]
@@ -130,16 +150,22 @@ const config = [
130
150
  export default config
131
151
 
132
152
  /**
133
- * @param {Object} options
134
- * @param {boolean} options.pnpmCatalogs
153
+ * @typedef {Object} KitqlOptions
154
+ * @property {PnpmCatalogsConfig} [pnpmCatalogs] - Configuration object for pnpm catalogs
155
+ */
156
+
157
+ /**
158
+ * @param {KitqlOptions} [options]
135
159
  * @returns {import('eslint').Linter.Config[]}
136
160
  */
137
- export const kitql = (options) => {
138
- const pnpmCatalogs = options?.pnpmCatalogs ?? true
161
+ export const kitql = (options = {}) => {
162
+ const pnpmCatalogsConfig = options?.pnpmCatalogs ?? { enable: true }
163
+ const pnpmCatalogsEnabled = pnpmCatalogsConfig.enable !== false
164
+
139
165
  return [
140
166
  //
141
- rulePrettierIgnore({ pnpmCatalogs }),
167
+ rulePrettierIgnore({ pnpmCatalogsEnabled }),
142
168
  ...othersRules(),
143
- ...(pnpmCatalogs ? [rulePnpmCatalogs()] : []),
169
+ ...(pnpmCatalogsEnabled ? [rulePnpmCatalogs(pnpmCatalogsConfig)] : []),
144
170
  ]
145
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitql/eslint-config",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "type": "module",
5
5
  "description": "opinionated linting and formatting for projects",
6
6
  "repository": {
@@ -16,12 +16,9 @@
16
16
  "kitql-lint": "./cmd.js"
17
17
  },
18
18
  "main": "eslint.config.js",
19
- "types": "eslint.config.d.ts",
20
19
  "files": [
21
20
  ".prettierrc.mjs",
22
21
  "cmd.js",
23
- "cmd.sh",
24
- "eslint.config.d.ts",
25
22
  "eslint.config.js",
26
23
  "helper/findFileOrUp.js"
27
24
  ],
@@ -32,12 +29,12 @@
32
29
  ],
33
30
  "dependencies": {
34
31
  "@eslint/compat": "1.2.7",
35
- "@eslint/js": "9.10.0",
32
+ "@eslint/js": "9.22.0",
36
33
  "@theguild/prettier-config": "3.0.0",
37
34
  "@types/eslint": "9.6.1",
38
35
  "@typescript-eslint/parser": "8.26.0",
39
36
  "commander": "13.1.0",
40
- "eslint": "9.10.0",
37
+ "eslint": "9.22.0",
41
38
  "eslint-plugin-pnpm-catalogs": "0.1.0",
42
39
  "eslint-plugin-svelte": "3.0.3",
43
40
  "eslint-plugin-unused-imports": "4.1.4",
@@ -1,17 +0,0 @@
1
- import type { Linter } from 'eslint'
2
-
3
- export default config
4
-
5
- /**
6
- * KitQL's ESLint configuration with customizable options
7
- *
8
- * @param options - Configuration options
9
- * @returns ESLint configuration array
10
- */
11
- export function kitql(options?: {
12
- /**
13
- * Whether to include pnpm catalogs rules
14
- * @default true
15
- */
16
- pnpmCatalogs?: boolean
17
- }): Linter.Config[]