@kitql/eslint-config 0.4.0-next.1 → 0.4.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.cjs CHANGED
@@ -27,5 +27,4 @@ module.exports = {
27
27
  '',
28
28
  '^[./]', // inside
29
29
  ],
30
- // importOrderSeparation: true,
31
30
  }
package/cmd.js CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawnSync } from 'node:child_process'
3
- import fs from 'node:fs'
4
3
  import { Option, program } from 'commander'
5
4
 
6
5
  import { Log, red } from '@kitql/helpers'
7
6
 
7
+ import { findFileOrUp } from './helper/findFileOrUp.js'
8
+
8
9
  const log = new Log('kitql-lint')
9
10
 
10
11
  program.addOption(new Option('-f, --format', 'format'))
@@ -21,23 +22,6 @@ program.addOption(
21
22
  program.parse(process.argv)
22
23
  const options_cli = program.opts()
23
24
 
24
- const findFileOrUp = (fileName) => {
25
- // Find file recursively 4 levels max up
26
- for (let i = 0; i < 4; i++) {
27
- try {
28
- const path = '../'.repeat(i) + fileName
29
- if (fs.statSync(path)) {
30
- return path
31
- }
32
- } catch (error) {
33
- // nothing to do
34
- }
35
- }
36
-
37
- log.error(red(`${fileName} not found`))
38
- process.exit(1)
39
- }
40
-
41
25
  const pathPrettierIgnore = findFileOrUp('.prettierignore')
42
26
  const pathPrettierCjs = findFileOrUp('.prettierrc.cjs')
43
27
 
@@ -86,8 +70,6 @@ function eslintRun() {
86
70
  const cmdEsLint =
87
71
  preToUse +
88
72
  `eslint` +
89
- // ignore?
90
- ` --ignore-pattern ${pathPrettierIgnore}` +
91
73
  // format or not
92
74
  `${format ? ' --fix' : ''}` +
93
75
  // exec
package/eslint.config.js CHANGED
@@ -1,15 +1,28 @@
1
+ import { includeIgnoreFile } from '@eslint/compat'
1
2
  import js from '@eslint/js'
2
3
  import svelte from 'eslint-plugin-svelte'
3
4
  import unusedImports from 'eslint-plugin-unused-imports'
4
5
  import globals from 'globals'
5
6
  import ts from 'typescript-eslint'
6
7
 
8
+ import { findFileOrUp } from './helper/findFileOrUp.js'
9
+
10
+ const pathPrettierIgnore = findFileOrUp('.prettierignore', { absolute: true })
11
+
7
12
  /** @type {import('eslint').Linter.Config[]} */
8
13
  export const config = [
9
- js.configs.recommended,
14
+ {
15
+ name: '@kitql:prettier:ignores',
16
+ ignores: includeIgnoreFile(pathPrettierIgnore).ignores,
17
+ },
18
+ {
19
+ name: 'eslint/defaults/recommended',
20
+ ...js.configs.recommended, // TODO, would be nice to have a name by default?
21
+ },
10
22
  ...ts.configs.recommended,
11
23
  ...svelte.configs['flat/recommended'],
12
24
  {
25
+ name: '@kitql:languages',
13
26
  languageOptions: {
14
27
  globals: {
15
28
  ...globals.browser,
@@ -18,6 +31,7 @@ export const config = [
18
31
  },
19
32
  },
20
33
  {
34
+ name: '@kitql:svelte:languages',
21
35
  files: ['**/*.svelte'],
22
36
  languageOptions: {
23
37
  parserOptions: {
@@ -26,10 +40,34 @@ export const config = [
26
40
  },
27
41
  },
28
42
  {
29
- ignores: ['build/', '.svelte-kit/', 'dist/'],
43
+ name: '@kitql:ignores',
44
+ ignores: ['build/', '.svelte-kit/', 'dist/', '**/build/', '**/.svelte-kit/', '**/dist/'],
30
45
  },
31
46
  {
32
- name: '@kitql rules',
47
+ name: '@kitql:unused-imports',
48
+ plugins: {
49
+ 'unused-imports': unusedImports,
50
+ },
51
+ rules: {
52
+ 'no-unused-vars': 'off',
53
+ '@typescript-eslint/no-unused-vars': 'off',
54
+
55
+ 'unused-imports/no-unused-imports': 'error',
56
+ 'unused-imports/no-unused-vars': 'off',
57
+ // 'unused-imports/no-unused-vars': [
58
+ // 'warn',
59
+ // {
60
+ // vars: 'all',
61
+ // varsIgnorePattern: '^_',
62
+ // args: 'after-used',
63
+ // argsIgnorePattern: '^_',
64
+ // },
65
+ // ],
66
+ 'no-empty': ['error', { allowEmptyCatch: true }],
67
+ },
68
+ },
69
+ {
70
+ name: '@kitql:rules',
33
71
  rules: {
34
72
  'no-console': [
35
73
  'error',
@@ -52,26 +90,6 @@ export const config = [
52
90
  'svelte/no-inner-declarations': 'off',
53
91
  },
54
92
  },
55
- {
56
- plugins: {
57
- 'unused-imports': unusedImports,
58
- },
59
- rules: {
60
- 'no-unused-vars': 'off', // or "@typescript-eslint/no-unused-vars": "off",
61
- '@typescript-eslint/no-unused-vars': 'off',
62
- 'unused-imports/no-unused-imports': 'error',
63
- 'unused-imports/no-unused-vars': 'off',
64
- // 'unused-imports/no-unused-vars': [
65
- // 'warn',
66
- // {
67
- // vars: 'all',
68
- // varsIgnorePattern: '^_',
69
- // args: 'after-used',
70
- // argsIgnorePattern: '^_',
71
- // },
72
- // ],
73
- },
74
- },
75
93
  ]
76
94
 
77
95
  export default config
@@ -0,0 +1,22 @@
1
+ import { statSync } from 'fs'
2
+ import { resolve } from 'path'
3
+
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
+ }
19
+
20
+ console.error(`"${fileName}" not found`)
21
+ return null
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitql/eslint-config",
3
- "version": "0.4.0-next.1",
3
+ "version": "0.4.0-next.3",
4
4
  "type": "module",
5
5
  "description": "opinionated linting and formatting for projects",
6
6
  "repository": {
@@ -19,7 +19,8 @@
19
19
  "cmd.js",
20
20
  "cmd.sh",
21
21
  "eslint.config.js",
22
- "eslint.config.d.ts"
22
+ "eslint.config.d.ts",
23
+ "helper/findFileOrUp.js"
23
24
  ],
24
25
  "keywords": [
25
26
  "cli",
@@ -30,11 +31,13 @@
30
31
  "prettier": "^3.3.3"
31
32
  },
32
33
  "dependencies": {
34
+ "@eslint/compat": "^1.1.1",
33
35
  "@eslint/js": "^9.10.0",
34
36
  "@theguild/prettier-config": "2.0.7",
35
37
  "@types/eslint": "9.6.1",
38
+ "@typescript-eslint/parser": "^8.5.0",
36
39
  "commander": "12.1.0",
37
- "eslint": "9.10.0",
40
+ "eslint": "^9.10.0",
38
41
  "eslint-plugin-svelte": "2.43.0",
39
42
  "eslint-plugin-unused-imports": "^4.1.3",
40
43
  "globals": "15.9.0",
@@ -52,6 +55,7 @@
52
55
  "format": "node ./cmd.js -f",
53
56
  "format:example": "kitql-lint --format",
54
57
  "lint": "node ./cmd.js --verbose -p none",
55
- "lint:example": "kitql-lint"
58
+ "lint:example": "kitql-lint",
59
+ "inspector": "npx @eslint/config-inspector"
56
60
  }
57
61
  }