@kitql/eslint-config 0.5.7 → 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/eslint.config.js +42 -16
- package/package.json +3 -6
- package/eslint.config.d.ts +0 -17
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
|
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({
|
|
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
|
-
* @
|
|
134
|
-
* @
|
|
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
|
|
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({
|
|
167
|
+
rulePrettierIgnore({ pnpmCatalogsEnabled }),
|
|
142
168
|
...othersRules(),
|
|
143
|
-
...(
|
|
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.
|
|
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.
|
|
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.
|
|
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",
|
package/eslint.config.d.ts
DELETED
|
@@ -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[]
|