@kitql/eslint-config 0.5.7 → 0.6.0-next.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/eslint.config.js CHANGED
@@ -1,39 +1,83 @@
1
1
  import { includeIgnoreFile } from '@eslint/compat'
2
2
  import js from '@eslint/js'
3
- import pnpmCatalogs from 'eslint-plugin-pnpm-catalogs'
3
+ import pluginPnpm from 'eslint-plugin-pnpm'
4
4
  import svelte from 'eslint-plugin-svelte'
5
5
  import unusedImports from 'eslint-plugin-unused-imports'
6
6
  import globals from 'globals'
7
7
  import * as jsoncParser from 'jsonc-eslint-parser'
8
8
  import ts from 'typescript-eslint'
9
+ import * as yamlParser from 'yaml-eslint-parser'
9
10
 
10
11
  import { findFileOrUp } from './helper/findFileOrUp.js'
11
12
 
12
- const rulePrettierIgnore = ({ pnpmCatalogs = true }) => {
13
+ /**
14
+ * @typedef {Object} PnpmCatalogsConfig
15
+ * @property {boolean} [enable=true] - Whether to enable pnpm catalogs rules
16
+ * @property {string[]} [json_files] - Files to apply the rules to
17
+ * @property {Record<string, any>} [json_rules] - Rules configuration
18
+ * @property {string[]} [yaml_files] - Files to apply the rules to
19
+ * @property {Record<string, any>} [yaml_rules] - Rules configuration
20
+ */
21
+
22
+ const rulePrettierIgnore = ({ pnpmCatalogsEnabled = true }) => {
13
23
  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
24
+ const rowIgnore = pathPrettierIgnore ? (includeIgnoreFile(pathPrettierIgnore).ignores ?? []) : []
25
+ const ignores = pnpmCatalogsEnabled
26
+ ? rowIgnore.filter((c) => !c.includes('package.json'))
27
+ : rowIgnore
16
28
  return {
17
29
  name: '@kitql:prettier:ignores',
18
30
  ignores,
19
31
  }
20
32
  }
21
33
 
22
- const rulePnpmCatalogs = () => {
23
- return {
24
- name: 'pnpm-catalogs:package.json',
25
- files: ['package.json'],
26
- languageOptions: {
27
- parser: jsoncParser,
34
+ /**
35
+ * @param {PnpmCatalogsConfig} options
36
+ */
37
+ const rulePnpmCatalogs = (options = {}) => {
38
+ const {
39
+ enable = true,
40
+ json_files = ['package.json', '**/package.json'],
41
+ json_rules = {
42
+ 'pnpm/json-enforce-catalog': 'error',
43
+ 'pnpm/json-valid-catalog': 'error',
44
+ 'pnpm/json-prefer-workspace-settings': 'error',
45
+ ...options.json_rules,
46
+ },
47
+ yaml_files = ['pnpm-workspace.yaml'],
48
+ yaml_rules = {
49
+ 'pnpm/yaml-no-unused-catalog-item': 'error',
50
+ 'pnpm/yaml-no-duplicate-catalog-item': 'off',
51
+ ...options.yaml_rules,
28
52
  },
29
- plugins: {
30
- 'pnpm-catalogs': pnpmCatalogs,
53
+ } = options
54
+
55
+ if (!enable) return []
56
+
57
+ return [
58
+ {
59
+ name: 'pnpm/package.json',
60
+ files: json_files,
61
+ languageOptions: {
62
+ parser: jsoncParser,
63
+ },
64
+ plugins: {
65
+ pnpm: pluginPnpm,
66
+ },
67
+ rules: json_rules,
31
68
  },
32
- rules: {
33
- 'pnpm-catalogs/enforce-catalog': 'error',
34
- 'pnpm-catalogs/valid-catalog': 'error',
69
+ {
70
+ name: 'pnpm/pnpm-workspace-yaml',
71
+ files: yaml_files,
72
+ languageOptions: {
73
+ parser: yamlParser,
74
+ },
75
+ plugins: {
76
+ pnpm: pluginPnpm,
77
+ },
78
+ rules: yaml_rules,
35
79
  },
36
- }
80
+ ]
37
81
  }
38
82
 
39
83
  const othersRules = () => {
@@ -122,24 +166,30 @@ const othersRules = () => {
122
166
  /** @type {import('eslint').Linter.Config[]} */
123
167
  const config = [
124
168
  //
125
- rulePrettierIgnore({ pnpmCatalogs: true }),
169
+ rulePrettierIgnore({ pnpmCatalogsEnabled: true }),
126
170
  ...othersRules(),
127
- rulePnpmCatalogs(),
171
+ ...rulePnpmCatalogs(),
128
172
  ]
129
173
 
130
174
  export default config
131
175
 
132
176
  /**
133
- * @param {Object} options
134
- * @param {boolean} options.pnpmCatalogs
177
+ * @typedef {Object} KitqlOptions
178
+ * @property {PnpmCatalogsConfig} [pnpmCatalogs] - Configuration object for pnpm catalogs
179
+ */
180
+
181
+ /**
182
+ * @param {KitqlOptions} [options]
135
183
  * @returns {import('eslint').Linter.Config[]}
136
184
  */
137
- export const kitql = (options) => {
138
- const pnpmCatalogs = options?.pnpmCatalogs ?? true
185
+ export const kitql = (options = {}) => {
186
+ const pnpmCatalogsConfig = options?.pnpmCatalogs ?? { enable: true }
187
+ const pnpmCatalogsEnabled = pnpmCatalogsConfig.enable !== false
188
+
139
189
  return [
140
190
  //
141
- rulePrettierIgnore({ pnpmCatalogs }),
191
+ rulePrettierIgnore({ pnpmCatalogsEnabled }),
142
192
  ...othersRules(),
143
- ...(pnpmCatalogs ? [rulePnpmCatalogs()] : []),
193
+ ...(pnpmCatalogsEnabled ? rulePnpmCatalogs(pnpmCatalogsConfig) : []),
144
194
  ]
145
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitql/eslint-config",
3
- "version": "0.5.7",
3
+ "version": "0.6.0-next.0",
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
  ],
@@ -30,24 +27,28 @@
30
27
  "eslint",
31
28
  "eslint-config"
32
29
  ],
30
+ "peerDependencies": {
31
+ "prettier": "^3.5.3"
32
+ },
33
33
  "dependencies": {
34
34
  "@eslint/compat": "1.2.7",
35
- "@eslint/js": "9.10.0",
35
+ "@eslint/js": "9.22.0",
36
36
  "@theguild/prettier-config": "3.0.0",
37
37
  "@types/eslint": "9.6.1",
38
38
  "@typescript-eslint/parser": "8.26.0",
39
39
  "commander": "13.1.0",
40
- "eslint": "9.10.0",
41
- "eslint-plugin-pnpm-catalogs": "0.1.0",
42
- "eslint-plugin-svelte": "3.0.3",
40
+ "eslint": "9.22.0",
41
+ "eslint-plugin-pnpm": "0.3.1",
42
+ "eslint-plugin-svelte": "3.1.0",
43
43
  "eslint-plugin-unused-imports": "4.1.4",
44
44
  "globals": "16.0.0",
45
45
  "jsonc-eslint-parser": "2.4.0",
46
46
  "ora": "8.2.0",
47
- "prettier": "3.5.3",
47
+ "prettier": "^3.5.3",
48
48
  "prettier-plugin-svelte": "3.3.2",
49
49
  "prettier-plugin-tailwindcss": "0.6.6",
50
50
  "typescript-eslint": "8.26.0",
51
+ "yaml-eslint-parser": "1.3.0",
51
52
  "@kitql/helpers": "0.8.12"
52
53
  },
53
54
  "publishConfig": {
@@ -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[]