@kitql/eslint-config 0.5.4 → 0.5.5

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.mjs CHANGED
@@ -1,30 +1,41 @@
1
1
  import prettierConfig from '@theguild/prettier-config'
2
2
 
3
3
  export default {
4
- ...prettierConfig,
5
- singleQuote: true,
6
- semi: false,
7
- arrowParens: 'always',
8
- plugins: [
9
- ...prettierConfig.plugins,
10
- 'prettier-plugin-svelte',
11
- 'prettier-plugin-tailwindcss', // MUST come last
12
- ],
13
- importOrderParserPlugins: ['typescript', 'decorators-legacy'],
14
- importOrder: [
15
- '<THIRD_PARTY_MODULES>',
16
- '',
17
- '^(\\$houdini)(.*)$', // special
18
- '^(remult)(.*)$', // special
19
- '^(firstly)(.*)$', // special
20
- '^(@kitql)(.*)$', // special
21
- '',
22
- '^(\\$env)(.*)$', // special sveltekit
23
- '^(\\$app)(.*)$', // special sveltekit
24
- '',
25
- '^(@app/common)(.*)$', // Aliases
26
- '^(\\$)(.*)$', // Aliases
27
- '',
28
- '^[./]', // inside
29
- ],
4
+ ...prettierConfig,
5
+ tabWidth: 1,
6
+ useTabs: true,
7
+ singleQuote: true,
8
+ semi: false,
9
+ arrowParens: 'always',
10
+ plugins: [
11
+ ...prettierConfig.plugins,
12
+ 'prettier-plugin-svelte',
13
+ 'prettier-plugin-tailwindcss', // MUST come last
14
+ ],
15
+ importOrderParserPlugins: ['typescript', 'decorators-legacy'],
16
+ importOrder: [
17
+ '<THIRD_PARTY_MODULES>',
18
+ '',
19
+ '^(\\$houdini)(.*)$', // special
20
+ '^(remult)(.*)$', // special
21
+ '^(firstly)(.*)$', // special
22
+ '^(@kitql)(.*)$', // special
23
+ '',
24
+ '^(\\$env)(.*)$', // special sveltekit
25
+ '^(\\$app)(.*)$', // special sveltekit
26
+ '',
27
+ '^(@app/common)(.*)$', // Aliases
28
+ '^(\\$)(.*)$', // Aliases
29
+ '',
30
+ '^[./]', // inside
31
+ ],
32
+ overrides: [
33
+ {
34
+ files: ['README.md', 'packages/**/README.md'],
35
+ options: {
36
+ useTabs: false,
37
+ tabWidth: 2,
38
+ },
39
+ },
40
+ ],
30
41
  }
package/README.md CHANGED
@@ -31,7 +31,7 @@ export default [...kitql]
31
31
  import config from './packages/eslint-config/.prettierrc.mjs'
32
32
 
33
33
  export default {
34
- ...config
34
+ ...config,
35
35
  // Some custom things?
36
36
  }
37
37
  ```
package/cmd.js CHANGED
@@ -1,16 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawn } from 'node:child_process'
3
+ import fs from 'node:fs'
4
+ import path from 'node:path'
3
5
  import { Option, program } from 'commander'
4
6
  import ora from 'ora'
5
7
 
6
- import { bgBlueBright, bgGreen, bgRedBright, gray, red } from '@kitql/helpers'
8
+ import { bgBlueBright, bgGreen, bgRedBright, gray, green, red } from '@kitql/helpers'
7
9
 
8
10
  import { findFileOrUp } from './helper/findFileOrUp.js'
9
11
 
12
+ // df
10
13
  const spinner = ora({
11
- // hideCursor: true,
12
- prefixText: bgBlueBright(` kitql-lint `),
13
- text: 'check config',
14
+ // hideCursor: true,
15
+ prefixText: bgBlueBright(` kitql-lint `),
16
+ text: 'check config',
14
17
  })
15
18
  spinner.start()
16
19
 
@@ -20,11 +23,17 @@ program.addOption(new Option('--eslint-only', 'only run eslint', false))
20
23
  program.addOption(new Option('--prettier-only', 'only run prettier', false))
21
24
  program.addOption(new Option('--verbose', 'add more logs', false))
22
25
  program.addOption(
23
- new Option(
24
- '-p, --prefix <type>',
25
- 'prefix by with "pnpm" or "npm" or "none" ("none" by default)',
26
- 'none',
27
- ),
26
+ new Option('-d, --diff-only', 'only check files changed against base branch', false),
27
+ )
28
+ program.addOption(
29
+ new Option('--base-branch <type>', 'base branch to compare against (default: main)', 'main'),
30
+ )
31
+ program.addOption(
32
+ new Option(
33
+ '-p, --prefix <type>',
34
+ 'prefix by with "pnpm" or "npm" or "none" ("none" by default)',
35
+ 'none',
36
+ ),
28
37
  )
29
38
 
30
39
  program.parse(process.argv)
@@ -34,113 +43,318 @@ const pathPrettierIgnore = findFileOrUp('.prettierignore')
34
43
  const pathPrettierMjs = findFileOrUp('.prettierrc.mjs')
35
44
 
36
45
  const format = options_cli.format ?? false
37
- const glob = options_cli.glob ?? '.'
46
+ let glob = options_cli.glob ?? '.'
38
47
  const verbose = options_cli.verbose ?? false
39
48
  const pre = options_cli.prefix ?? 'none'
40
49
  const eslintOnly = options_cli.eslintOnly ?? false
41
50
  const prettierOnly = options_cli.prettierOnly ?? false
51
+ const diffOnly = options_cli.diffOnly ?? false
52
+ const baseBranch = options_cli.baseBranch ?? 'main'
42
53
 
43
54
  let preToUse = ''
44
55
  if (pre === 'npm') {
45
- preToUse = 'npm exec '
56
+ preToUse = 'npm exec '
46
57
  } else if (pre === 'pnpm') {
47
- preToUse = 'pnpm '
58
+ preToUse = 'pnpm '
48
59
  } else {
49
- preToUse = ''
60
+ preToUse = ''
50
61
  }
51
62
 
52
63
  async function customSpawn(cmd) {
53
- const child = spawn(cmd, {
54
- shell: true,
55
- cwd: process.cwd(),
56
- stdio: 'inherit',
57
- })
58
- // console.log(`child`, child)
59
-
60
- let data = ''
61
- // for await (const chunk of child?.stdout) {
62
- // console.log('stdout chunk: ' + chunk)
63
- // data += chunk
64
- // }
65
- let error = ''
66
- // for await (const chunk of child?.stderr) {
67
- // console.error('stderr chunk: ' + chunk)
68
- // error += chunk
69
- // }
70
- const exitCode = await new Promise((resolve, reject) => {
71
- child.on('close', resolve)
72
- })
73
-
74
- if (exitCode) {
75
- // throw new Error(`subprocess error exit ${exitCode}, ${error}`)
76
- return { status: exitCode, error }
77
- }
78
- return data
64
+ const child = spawn(cmd, {
65
+ shell: true,
66
+ cwd: process.cwd(),
67
+ stdio: 'inherit',
68
+ })
69
+ // console.log(`child`, child)
70
+
71
+ let data = ''
72
+ // for await (const chunk of child?.stdout) {
73
+ // console.log('stdout chunk: ' + chunk)
74
+ // data += chunk
75
+ // }
76
+ let error = ''
77
+ // for await (const chunk of child?.stderr) {
78
+ // console.error('stderr chunk: ' + chunk)
79
+ // error += chunk
80
+ // }
81
+ const exitCode = await new Promise((resolve, reject) => {
82
+ child.on('close', resolve)
83
+ })
84
+
85
+ if (exitCode) {
86
+ // throw new Error(`subprocess error exit ${exitCode}, ${error}`)
87
+ return { status: exitCode, error }
88
+ }
89
+ return data
90
+ }
91
+
92
+ let filesLength = -1
93
+ async function getDiffFiles() {
94
+ spinner.text = verbose
95
+ ? 'git diff ' + gray(`(getting changed files against ${baseBranch})`)
96
+ : 'git diff'
97
+
98
+ // First, get the git repository root
99
+ let gitRootPath = ''
100
+ try {
101
+ const gitRootCmd = 'git rev-parse --show-toplevel'
102
+ const gitRootChild = spawn(gitRootCmd, {
103
+ shell: true,
104
+ cwd: process.cwd(),
105
+ })
106
+
107
+ let rootData = ''
108
+ for await (const chunk of gitRootChild.stdout) {
109
+ rootData += chunk
110
+ }
111
+
112
+ const gitRootExitCode = await new Promise((resolve) => {
113
+ gitRootChild.on('close', resolve)
114
+ })
115
+
116
+ if (gitRootExitCode === 0) {
117
+ gitRootPath = rootData.trim()
118
+ } else {
119
+ spinner.warn('Could not determine git repository root')
120
+ return null
121
+ }
122
+ } catch (error) {
123
+ spinner.warn(`Error getting git root: ${error.message}`)
124
+ return null
125
+ }
126
+
127
+ // Try to find the best base branch to compare against
128
+ const possibleBranches = [baseBranch, 'main', 'HEAD~1']
129
+ let validBranch = null
130
+
131
+ for (const branch of possibleBranches) {
132
+ try {
133
+ // Check if the branch exists
134
+ const checkBranchCmd = `git rev-parse --verify ${branch}`
135
+ const checkBranchChild = spawn(checkBranchCmd, {
136
+ shell: true,
137
+ cwd: process.cwd(),
138
+ })
139
+
140
+ const branchExitCode = await new Promise((resolve) => {
141
+ checkBranchChild.on('close', resolve)
142
+ })
143
+
144
+ if (branchExitCode === 0) {
145
+ validBranch = branch
146
+ if (verbose && branch !== baseBranch) {
147
+ spinner.info(`Using '${branch}' as base branch instead of '${baseBranch}'`)
148
+ }
149
+ break
150
+ }
151
+ } catch (error) {
152
+ // Continue to next branch
153
+ }
154
+ }
155
+
156
+ if (!validBranch) {
157
+ // If in CI, try to use a different approach
158
+ if (process.env.CI) {
159
+ try {
160
+ // In CI, we can try to get all staged and unstaged changes
161
+ validBranch = 'HEAD'
162
+ if (verbose) {
163
+ spinner.info('In CI environment, checking all changes')
164
+ }
165
+ } catch (error) {
166
+ spinner.warn(`Could not find a valid base branch to compare against`)
167
+ return null
168
+ }
169
+ } else {
170
+ spinner.warn(`Could not find a valid base branch to compare against`)
171
+ return null
172
+ }
173
+ }
174
+
175
+ // Now get the changed files
176
+ const cmd = `git diff --name-only --diff-filter=ACMR ${validBranch}`
177
+
178
+ try {
179
+ const child = spawn(cmd, {
180
+ shell: true,
181
+ cwd: process.cwd(),
182
+ })
183
+
184
+ let data = ''
185
+ for await (const chunk of child.stdout) {
186
+ data += chunk
187
+ }
188
+
189
+ let error = ''
190
+ for await (const chunk of child.stderr) {
191
+ error += chunk
192
+ }
193
+
194
+ const exitCode = await new Promise((resolve) => {
195
+ child.on('close', resolve)
196
+ })
197
+
198
+ if (exitCode) {
199
+ // If the diff command failed, try a fallback approach for CI environments
200
+ if (process.env.CI) {
201
+ try {
202
+ // In CI, we can try to get all tracked files that have changes
203
+ const fallbackCmd = 'git ls-files --modified --others --exclude-standard'
204
+ const fallbackChild = spawn(fallbackCmd, {
205
+ shell: true,
206
+ cwd: process.cwd(),
207
+ })
208
+
209
+ let fallbackData = ''
210
+ for await (const chunk of fallbackChild.stdout) {
211
+ fallbackData += chunk
212
+ }
213
+
214
+ const fallbackExitCode = await new Promise((resolve) => {
215
+ fallbackChild.on('close', resolve)
216
+ })
217
+
218
+ if (fallbackExitCode === 0 && fallbackData.trim()) {
219
+ data = fallbackData
220
+ if (verbose) {
221
+ spinner.info('Using fallback method to get changed files in CI')
222
+ }
223
+ } else {
224
+ spinner.warn(`Could not get changed files: ${error}`)
225
+ return null
226
+ }
227
+ } catch (fallbackError) {
228
+ spinner.warn(`Could not get changed files: ${error}`)
229
+ return null
230
+ }
231
+ } else {
232
+ spinner.warn(`Could not get changed files: ${error}`)
233
+ return null
234
+ }
235
+ }
236
+
237
+ // Get the current working directory
238
+ const cwd = process.cwd()
239
+
240
+ // Process the files to make them relative to the current working directory
241
+ const files = data
242
+ .trim()
243
+ .split('\n')
244
+ .filter(Boolean)
245
+ .map((file) => {
246
+ // Convert the git path (relative to git root) to an absolute path
247
+ const absolutePath = path.join(gitRootPath, file)
248
+
249
+ // Convert the absolute path to a path relative to the current working directory
250
+ const relativePath = path.relative(cwd, absolutePath)
251
+
252
+ // Check if the file exists and is at or below the current directory
253
+ if (fs.existsSync(relativePath) && !relativePath.startsWith('..')) {
254
+ return relativePath
255
+ }
256
+ return null
257
+ })
258
+ .filter(Boolean) // Remove null entries (files not at or below current directory)
259
+
260
+ filesLength = files.length
261
+ if (verbose) {
262
+ spinner.info(`Found ${filesLength} changed files at or below current directory`)
263
+ }
264
+
265
+ // Format the files for the command line, wrapping each in quotes and joining with spaces
266
+ return files.length > 0 ? files.map((f) => `'${f}'`).join(' ') : null
267
+ } catch (error) {
268
+ spinner.warn(`Error getting changed files: ${error.message}`)
269
+ return null
270
+ }
79
271
  }
80
272
 
81
273
  async function eslintRun() {
82
- const cmdEsLint =
83
- preToUse +
84
- `eslint` +
85
- // format or not
86
- `${format ? ' --fix' : ''}` +
87
- // exec
88
- ` ${glob}`
274
+ const cmdEsLint =
275
+ preToUse +
276
+ `eslint --no-warn-ignored` +
277
+ // format or not
278
+ `${format ? ' --fix' : ''}` +
279
+ // exec
280
+ ` ${glob}`
89
281
 
90
- spinner.text = verbose ? 'eslint ' + gray(`(${cmdEsLint})`) : 'eslint'
282
+ spinner.text = verbose ? 'eslint ' + gray(`(${cmdEsLint})`) : 'eslint'
91
283
 
92
- const result_eslint = await customSpawn(cmdEsLint)
284
+ const result_eslint = await customSpawn(cmdEsLint)
93
285
 
94
- return result_eslint
286
+ return result_eslint
95
287
  }
96
288
 
97
289
  async function prettierRun() {
98
- const cmdPrettier =
99
- preToUse +
100
- `prettier` +
101
- ` --list-different` +
102
- // ignore?
103
- ` --ignore-path ${pathPrettierIgnore}` +
104
- // config
105
- ` --config ${pathPrettierMjs}` +
106
- // format or not
107
- `${format ? ' --write' : ''}` +
108
- // exec
109
- ` ${glob}`
110
-
111
- spinner.text = verbose ? 'prettier ' + gray(`(${cmdPrettier})`) : 'prettier'
112
-
113
- const result_prettier = await customSpawn(cmdPrettier)
114
-
115
- return result_prettier
290
+ const cmdPrettier =
291
+ preToUse +
292
+ `prettier` +
293
+ ` --list-different` +
294
+ // ignore?
295
+ ` --ignore-path ${pathPrettierIgnore}` +
296
+ // config
297
+ ` --config ${pathPrettierMjs}` +
298
+ // format or not
299
+ `${format ? ' --write' : ''}` +
300
+ // exec
301
+ ` ${glob}`
302
+
303
+ spinner.text = verbose ? 'prettier ' + gray(`(${cmdPrettier})`) : 'prettier'
304
+
305
+ const result_prettier = await customSpawn(cmdPrettier)
306
+
307
+ return result_prettier
116
308
  }
117
309
 
118
310
  const took = []
119
- if (!prettierOnly) {
120
- const esLintStart = Date.now()
121
- const eslintCode = await eslintRun()
122
- const esLintTook = Date.now() - esLintStart
123
- took.push(`eslint: ${esLintTook}ms`)
124
- if (eslintCode.status) {
125
- spinner.prefixText = bgRedBright(` kitql-lint `)
126
- spinner.fail(red(`eslint failed, check logs above.`))
127
- process.exit(eslintCode.status)
128
- }
311
+
312
+ const display = (text, time) => {
313
+ return `${gray(text)} ${green((time / 1000).toFixed(3))}${gray('s')}`
314
+ }
315
+
316
+ // If changed-only flag is set, get the list of changed files
317
+ if (diffOnly) {
318
+ spinner.text = 'Checking for changed files'
319
+ const changedFilesStart = performance.now()
320
+ const changedFiles = await getDiffFiles()
321
+ const changedFilesTook = performance.now() - changedFilesStart
322
+ took.push(display('diff', changedFilesTook))
323
+
324
+ if (changedFiles) {
325
+ glob = changedFiles
326
+ } else {
327
+ glob = ''
328
+ }
129
329
  }
130
330
 
131
- if (!eslintOnly) {
132
- const prettierStart = Date.now()
133
- const prettierCode = await prettierRun()
134
- const prettierTook = Date.now() - prettierStart
135
- took.push(`prettier: ${prettierTook}ms`)
136
- if (prettierCode.status) {
137
- spinner.prefixText = bgRedBright(` kitql-lint `)
138
- spinner.fail(red(`prettier failed, check logs above.`))
139
- process.exit(prettierCode.status)
140
- }
331
+ if (!prettierOnly && glob) {
332
+ const esLintStart = performance.now()
333
+ const eslintCode = await eslintRun()
334
+ const esLintTook = performance.now() - esLintStart
335
+ took.push(display('eslint', esLintTook))
336
+ if (eslintCode.status) {
337
+ spinner.prefixText = bgRedBright(` kitql-lint `)
338
+ spinner.fail(red(`eslint failed, check logs above.`))
339
+ process.exit(eslintCode.status)
340
+ }
341
+ }
342
+
343
+ if (!eslintOnly && glob) {
344
+ const prettierStart = performance.now()
345
+ const prettierCode = await prettierRun()
346
+ const prettierTook = performance.now() - prettierStart
347
+ took.push(display('prettier', prettierTook))
348
+ if (prettierCode.status) {
349
+ spinner.prefixText = bgRedBright(` kitql-lint `)
350
+ spinner.fail(red(`prettier failed, check logs above.`))
351
+ process.exit(prettierCode.status)
352
+ }
141
353
  }
142
354
 
143
355
  spinner.prefixText = bgGreen(` kitql-lint `)
144
- spinner.succeed(`All good, your files looks great! ${gray(`(${took.join(', ')})`)}`)
356
+ 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
+ )
145
359
  spinner.stop()
146
360
  process.exit(0)
package/eslint.config.js CHANGED
@@ -4,6 +4,7 @@ import pnpmCatalogs from 'eslint-plugin-pnpm-catalogs'
4
4
  import svelte from 'eslint-plugin-svelte'
5
5
  import unusedImports from 'eslint-plugin-unused-imports'
6
6
  import globals from 'globals'
7
+ import * as jsoncParser from 'jsonc-eslint-parser'
7
8
  import ts from 'typescript-eslint'
8
9
 
9
10
  import { findFileOrUp } from './helper/findFileOrUp.js'
@@ -12,98 +13,104 @@ const pathPrettierIgnore = findFileOrUp('.prettierignore', { absolute: true })
12
13
 
13
14
  /** @type {import('eslint').Linter.Config[]} */
14
15
  export const config = [
15
- {
16
- name: '@kitql:prettier:ignores',
17
- ignores: pathPrettierIgnore ? includeIgnoreFile(pathPrettierIgnore).ignores : [],
18
- },
19
- {
20
- name: 'eslint/defaults/recommended',
21
- ...js.configs.recommended, // TODO, would be nice to have a name by default?
22
- },
23
- ...ts.configs.recommended,
24
- ...svelte.configs['flat/recommended'],
25
- {
26
- name: '@kitql:languages',
27
- languageOptions: {
28
- globals: {
29
- ...globals.browser,
30
- ...globals.node,
31
- },
32
- },
33
- },
34
- {
35
- name: '@kitql:svelte:languages',
36
- files: ['**/*.svelte'],
37
- languageOptions: {
38
- parserOptions: {
39
- parser: ts.parser,
40
- },
41
- },
42
- },
43
- {
44
- name: '@kitql:ignores',
45
- ignores: ['build/', '.svelte-kit/', 'dist/', '**/build/', '**/.svelte-kit/', '**/dist/'],
46
- },
47
- {
48
- name: '@kitql:unused-imports',
49
- plugins: {
50
- 'unused-imports': unusedImports,
51
- },
52
- rules: {
53
- 'no-unused-vars': 'off',
54
- '@typescript-eslint/no-unused-vars': 'off',
16
+ {
17
+ name: '@kitql:prettier:ignores',
18
+ ignores: pathPrettierIgnore
19
+ ? includeIgnoreFile(pathPrettierIgnore).ignores.filter((c) => !c.includes('package.json'))
20
+ : [],
21
+ },
22
+ {
23
+ name: 'eslint/defaults/recommended',
24
+ ...js.configs.recommended, // TODO, would be nice to have a name by default?
25
+ },
26
+ ...ts.configs.recommended,
27
+ ...svelte.configs['flat/recommended'],
28
+ {
29
+ name: '@kitql:languages',
30
+ languageOptions: {
31
+ globals: {
32
+ ...globals.browser,
33
+ ...globals.node,
34
+ },
35
+ },
36
+ },
37
+ {
38
+ name: '@kitql:svelte:languages',
39
+ files: ['**/*.svelte'],
40
+ languageOptions: {
41
+ parserOptions: {
42
+ parser: ts.parser,
43
+ },
44
+ },
45
+ },
46
+ {
47
+ name: '@kitql:ignores',
48
+ ignores: ['build/', '.svelte-kit/', 'dist/', '**/build/', '**/.svelte-kit/', '**/dist/'],
49
+ },
50
+ {
51
+ name: '@kitql:unused-imports',
52
+ plugins: {
53
+ 'unused-imports': unusedImports,
54
+ },
55
+ rules: {
56
+ 'no-unused-vars': 'off',
57
+ '@typescript-eslint/no-unused-vars': 'off',
55
58
 
56
- 'unused-imports/no-unused-imports': 'error',
57
- 'unused-imports/no-unused-vars': 'off',
58
- // 'unused-imports/no-unused-vars': [
59
- // 'warn',
60
- // {
61
- // vars: 'all',
62
- // varsIgnorePattern: '^_',
63
- // args: 'after-used',
64
- // argsIgnorePattern: '^_',
65
- // },
66
- // ],
67
- 'no-empty': ['error', { allowEmptyCatch: true }],
68
- },
69
- },
70
- {
71
- name: '@kitql:pnpmCatalogs',
72
- plugins: {
73
- pnpmCatalogs,
74
- },
75
- rules: {
76
- 'pnpmCatalogs/enforce-catalog': 'error',
77
- 'pnpmCatalogs/valid-catalog': 'error',
78
- },
79
- },
80
- {
81
- name: '@kitql:rules',
82
- rules: {
83
- 'no-console': [
84
- 'error',
85
- {
86
- allow: ['info', 'warn', 'error', 'time', 'timeEnd', 'dir'],
87
- },
88
- ],
59
+ 'unused-imports/no-unused-imports': 'error',
60
+ 'unused-imports/no-unused-vars': 'off',
61
+ // 'unused-imports/no-unused-vars': [
62
+ // 'warn',
63
+ // {
64
+ // vars: 'all',
65
+ // varsIgnorePattern: '^_',
66
+ // args: 'after-used',
67
+ // argsIgnorePattern: '^_',
68
+ // },
69
+ // ],
70
+ 'no-empty': ['error', { allowEmptyCatch: true }],
71
+ },
72
+ },
73
+ {
74
+ name: 'pnpm-catalogs:package.json',
75
+ files: ['package.json'],
76
+ languageOptions: {
77
+ parser: jsoncParser,
78
+ },
79
+ plugins: {
80
+ 'pnpm-catalogs': pnpmCatalogs,
81
+ },
82
+ rules: {
83
+ 'pnpm-catalogs/enforce-catalog': 'error',
84
+ 'pnpm-catalogs/valid-catalog': 'error',
85
+ },
86
+ },
87
+ {
88
+ name: '@kitql:rules',
89
+ rules: {
90
+ 'no-console': [
91
+ 'error',
92
+ {
93
+ allow: ['info', 'warn', 'error', 'time', 'timeEnd', 'dir'],
94
+ },
95
+ ],
89
96
 
90
- '@typescript-eslint/no-require-imports': 'off',
91
- '@typescript-eslint/ban-ts-ignore': 'off',
92
- '@typescript-eslint/ban-ts-comment': 'off',
93
- '@typescript-eslint/no-explicit-any': 'off',
94
- '@typescript-eslint/no-non-null-assertion': 'off',
95
- '@typescript-eslint/no-unused-expressions': 'off',
96
- '@typescript-eslint/no-empty-object-type': 'off',
97
+ '@typescript-eslint/no-require-imports': 'off',
98
+ '@typescript-eslint/ban-ts-ignore': 'off',
99
+ '@typescript-eslint/ban-ts-comment': 'off',
100
+ '@typescript-eslint/no-explicit-any': 'off',
101
+ '@typescript-eslint/no-non-null-assertion': 'off',
102
+ '@typescript-eslint/no-unused-expressions': 'off',
103
+ '@typescript-eslint/no-empty-object-type': 'off',
97
104
 
98
- 'no-undef': 'off',
99
- 'no-inner-declarations': 'off',
105
+ 'no-undef': 'off',
106
+ 'no-inner-declarations': 'off',
100
107
 
101
- 'svelte/no-at-html-tags': 'off',
102
- 'svelte/no-inner-declarations': 'off',
108
+ 'svelte/no-at-html-tags': 'off',
109
+ 'svelte/no-inner-declarations': 'off',
103
110
 
104
- 'svelte/require-each-key': 'warn',
105
- },
106
- },
111
+ 'svelte/require-each-key': 'warn',
112
+ },
113
+ },
107
114
  ]
108
115
 
109
116
  export default config
@@ -2,21 +2,21 @@ import { statSync } from 'node:fs'
2
2
  import { resolve } from 'node:path'
3
3
 
4
4
  export const findFileOrUp = (fileName, options) => {
5
- // Find file recursively 4 levels max up
6
- for (let i = 0; i < 4; i++) {
7
- try {
8
- const pathFound = '../'.repeat(i) + fileName
9
- if (statSync(pathFound)) {
10
- if (options?.absolute) {
11
- return resolve(pathFound)
12
- }
13
- return pathFound
14
- }
15
- } catch (error) {
16
- // nothing to do
17
- }
18
- }
5
+ // Find file recursively 4 levels max up
6
+ for (let i = 0; i < 4; i++) {
7
+ try {
8
+ const pathFound = '../'.repeat(i) + fileName
9
+ if (statSync(pathFound)) {
10
+ if (options?.absolute) {
11
+ return resolve(pathFound)
12
+ }
13
+ return pathFound
14
+ }
15
+ } catch (error) {
16
+ // nothing to do
17
+ }
18
+ }
19
19
 
20
- console.error(`"${fileName}" not found`)
21
- return null
20
+ console.error(`"${fileName}" not found`)
21
+ return null
22
22
  }
package/package.json CHANGED
@@ -1,9 +1,7 @@
1
1
  {
2
2
  "name": "@kitql/eslint-config",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "type": "module",
5
- "funding": "https://github.com/sponsors/jycouet",
6
- "homepage": "https://www.kitql.dev/",
7
5
  "description": "opinionated linting and formatting for projects",
8
6
  "repository": {
9
7
  "type": "git",
@@ -11,6 +9,8 @@
11
9
  "directory": "packages/eslint-config",
12
10
  "homepage": "https://github.com/jycouet/kitql/tree/main/packages/eslint-config"
13
11
  },
12
+ "homepage": "https://www.kitql.dev/",
13
+ "funding": "https://github.com/sponsors/jycouet",
14
14
  "license": "MIT",
15
15
  "bin": {
16
16
  "kitql-lint": "./cmd.js"
@@ -20,8 +20,8 @@
20
20
  ".prettierrc.mjs",
21
21
  "cmd.js",
22
22
  "cmd.sh",
23
- "eslint.config.js",
24
23
  "eslint.config.d.ts",
24
+ "eslint.config.js",
25
25
  "helper/findFileOrUp.js"
26
26
  ],
27
27
  "keywords": [
@@ -30,18 +30,19 @@
30
30
  "eslint-config"
31
31
  ],
32
32
  "dependencies": {
33
- "@eslint/compat": "^1.1.1",
34
- "@eslint/js": "^9.10.0",
33
+ "@eslint/compat": "1.2.7",
34
+ "@eslint/js": "9.10.0",
35
35
  "@theguild/prettier-config": "3.0.0",
36
36
  "@types/eslint": "9.6.1",
37
- "@typescript-eslint/parser": "8.5.0",
37
+ "@typescript-eslint/parser": "8.26.0",
38
38
  "commander": "13.1.0",
39
- "eslint": "^9.10.0",
40
- "eslint-plugin-pnpm-catalogs": "0.0.2",
39
+ "eslint": "9.10.0",
40
+ "eslint-plugin-pnpm-catalogs": "0.1.0",
41
41
  "eslint-plugin-svelte": "3.0.3",
42
42
  "eslint-plugin-unused-imports": "4.1.4",
43
43
  "globals": "16.0.0",
44
- "ora": "8.1.0",
44
+ "jsonc-eslint-parser": "2.4.0",
45
+ "ora": "8.2.0",
45
46
  "prettier": "3.5.3",
46
47
  "prettier-plugin-svelte": "3.3.2",
47
48
  "prettier-plugin-tailwindcss": "0.6.6",
@@ -53,7 +54,7 @@
53
54
  },
54
55
  "sideEffects": false,
55
56
  "scripts": {
56
- "format": "node ./cmd.js -f",
57
+ "format": "node ./cmd.js -f -d --verbose",
57
58
  "format:example": "kitql-lint --format",
58
59
  "lint": "node ./cmd.js --verbose -p none",
59
60
  "lint:example": "kitql-lint",