@kitql/eslint-config 0.3.7 → 0.4.0-next.1

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,5 @@ module.exports = {
27
27
  '',
28
28
  '^[./]', // inside
29
29
  ],
30
- importOrderSeparation: true,
30
+ // importOrderSeparation: true,
31
31
  }
package/README.md CHANGED
@@ -18,7 +18,7 @@ npm install @kitql/eslint-config --D
18
18
  `.eslintrc.js`
19
19
 
20
20
  ```js
21
- /** @type { import("eslint").Linter.FlatConfig } */
21
+ /** @type { import("eslint").Linter.Config } */
22
22
  module.exports = {
23
23
  extends: ['@kitql'],
24
24
  rules: {}
package/cmd.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { spawn, spawnSync } from 'child_process'
3
- import fs from 'fs'
2
+ import { spawnSync } from 'node:child_process'
3
+ import fs from 'node:fs'
4
4
  import { Option, program } from 'commander'
5
5
 
6
6
  import { Log, red } from '@kitql/helpers'
@@ -38,8 +38,8 @@ const findFileOrUp = (fileName) => {
38
38
  process.exit(1)
39
39
  }
40
40
 
41
- let pathPrettierIgnore = findFileOrUp('.prettierignore')
42
- let pathPrettierCjs = findFileOrUp('.prettierrc.cjs')
41
+ const pathPrettierIgnore = findFileOrUp('.prettierignore')
42
+ const pathPrettierCjs = findFileOrUp('.prettierrc.cjs')
43
43
 
44
44
  const format = options_cli.format ?? false
45
45
  const glob = options_cli.glob ?? '.'
@@ -55,60 +55,39 @@ if (pre === 'npm') {
55
55
  preToUse = ''
56
56
  }
57
57
 
58
- // First prettier
59
- const cmdPrettier =
60
- preToUse +
61
- `prettier` +
62
- ` --list-different` +
63
- // ignore?
64
- ` --ignore-path ${pathPrettierIgnore}` +
65
- // config
66
- ` --config ${pathPrettierCjs}` +
67
- // format or not
68
- `${format ? ' --write' : ''}` +
69
- // exec
70
- ` ${glob}`
71
-
72
- if (verbose) {
73
- log.info(cmdPrettier)
74
- }
75
- let result_prettier = spawn(cmdPrettier, {
76
- shell: true,
77
- cwd: process.cwd(),
78
- stdio: 'pipe',
79
- })
80
-
81
- // let's not log anything when we are formating prettier
82
- if (!format) {
83
- const logPrettier = new Log('kitql-lint prettier')
84
- result_prettier.stdout.on('data', (data) => {
85
- logPrettier.error(
86
- data
87
- .toString()
88
- // rmv the last \n if any
89
- .replace(/\n$/, ''),
90
- )
91
- })
92
- }
93
- if (format && verbose) {
94
- const logPrettier = new Log('kitql-lint prettier')
95
- result_prettier.stdout.on('data', (data) => {
96
- logPrettier.success(
97
- data
98
- .toString()
99
- // rmv the last \n if any
100
- .replace(/\n$/, ''),
101
- )
58
+ function prettierRun() {
59
+ const cmdPrettier =
60
+ preToUse +
61
+ `prettier` +
62
+ ` --list-different` +
63
+ // ignore?
64
+ ` --ignore-path ${pathPrettierIgnore}` +
65
+ // config
66
+ ` --config ${pathPrettierCjs}` +
67
+ // format or not
68
+ `${format ? ' --write' : ''}` +
69
+ // exec
70
+ ` ${glob}`
71
+
72
+ if (verbose) {
73
+ log.info(cmdPrettier)
74
+ }
75
+ const result_prettier = spawnSync(cmdPrettier, {
76
+ shell: true,
77
+ cwd: process.cwd(),
78
+ stdio: 'inherit',
102
79
  })
80
+
81
+ return result_prettier
103
82
  }
104
83
 
105
- function esLintRun(code) {
84
+ function eslintRun() {
106
85
  // Then eslint
107
86
  const cmdEsLint =
108
87
  preToUse +
109
88
  `eslint` +
110
89
  // ignore?
111
- ` --ignore-path ${pathPrettierIgnore}` +
90
+ ` --ignore-pattern ${pathPrettierIgnore}` +
112
91
  // format or not
113
92
  `${format ? ' --fix' : ''}` +
114
93
  // exec
@@ -118,53 +97,26 @@ function esLintRun(code) {
118
97
  log.info(cmdEsLint)
119
98
  }
120
99
 
121
- let result_eslint = spawnSync(cmdEsLint, {
100
+ const result_eslint = spawnSync(cmdEsLint, {
122
101
  shell: true,
123
102
  cwd: process.cwd(),
124
103
  stdio: 'inherit',
125
104
  })
126
105
 
127
- if (result_eslint.status) {
128
- log.error(red(`eslint failed, check logs above.`))
129
- }
130
-
131
- if (code === 0 && result_eslint.status === 0) {
132
- log.success(`All good, your files looks great!`)
133
- }
106
+ return result_eslint
107
+ }
134
108
 
135
- process.exit(code || result_eslint.status)
109
+ const eslintCode = eslintRun()
110
+ if (eslintCode.status) {
111
+ log.error(red(`eslint failed, check logs above.`))
112
+ process.exit(eslintCode.status)
136
113
  }
137
114
 
138
- result_prettier.stdout.on('end', (data) => {
139
- if (verbose) {
140
- log.info(`end`, data)
141
- }
142
- })
143
- result_prettier.stdout.on('error', (data) => {
144
- if (verbose) {
145
- log.info(`error`, data)
146
- }
147
- })
148
- result_prettier.stdout.on('pause', (data) => {
149
- if (verbose) {
150
- log.info(`pause`, data)
151
- }
152
- })
153
- result_prettier.stdout.on('readable', (data) => {
154
- if (verbose) {
155
- log.info(`readable`, data)
156
- }
157
- })
158
- result_prettier.stdout.on('resume', (data) => {
159
- if (verbose && data) {
160
- log.info(`resume`, data)
161
- }
162
- esLintRun(0)
163
- })
115
+ const prettierCode = prettierRun()
116
+ if (prettierCode.status) {
117
+ log.error(red(`prettier failed, check logs above.`))
118
+ process.exit(eslintCode.status)
119
+ }
164
120
 
165
- result_prettier.on('close', (data) => {
166
- if (verbose) {
167
- log.info(`close`, data)
168
- }
169
- esLintRun(data)
170
- })
121
+ log.success(`All good, your files looks great!`)
122
+ process.exit(0)
File without changes
@@ -0,0 +1,77 @@
1
+ import js from '@eslint/js'
2
+ import svelte from 'eslint-plugin-svelte'
3
+ import unusedImports from 'eslint-plugin-unused-imports'
4
+ import globals from 'globals'
5
+ import ts from 'typescript-eslint'
6
+
7
+ /** @type {import('eslint').Linter.Config[]} */
8
+ export const config = [
9
+ js.configs.recommended,
10
+ ...ts.configs.recommended,
11
+ ...svelte.configs['flat/recommended'],
12
+ {
13
+ languageOptions: {
14
+ globals: {
15
+ ...globals.browser,
16
+ ...globals.node,
17
+ },
18
+ },
19
+ },
20
+ {
21
+ files: ['**/*.svelte'],
22
+ languageOptions: {
23
+ parserOptions: {
24
+ parser: ts.parser,
25
+ },
26
+ },
27
+ },
28
+ {
29
+ ignores: ['build/', '.svelte-kit/', 'dist/'],
30
+ },
31
+ {
32
+ name: '@kitql rules',
33
+ rules: {
34
+ 'no-console': [
35
+ 'error',
36
+ {
37
+ allow: ['info', 'warn', 'error', 'time', 'timeEnd', 'dir'],
38
+ },
39
+ ],
40
+
41
+ '@typescript-eslint/no-require-imports': 'off',
42
+ '@typescript-eslint/ban-ts-ignore': 'off',
43
+ '@typescript-eslint/ban-ts-comment': 'off',
44
+ '@typescript-eslint/no-explicit-any': 'off',
45
+ '@typescript-eslint/no-non-null-assertion': 'off',
46
+ '@typescript-eslint/no-unused-expressions': 'off',
47
+ '@typescript-eslint/no-empty-object-type': 'off',
48
+
49
+ 'no-undef': 'off',
50
+ 'no-inner-declarations': 'off',
51
+ 'svelte/no-at-html-tags': 'off',
52
+ 'svelte/no-inner-declarations': 'off',
53
+ },
54
+ },
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
+ ]
76
+
77
+ export default config
package/package.json CHANGED
@@ -1,58 +1,57 @@
1
1
  {
2
2
  "name": "@kitql/eslint-config",
3
- "description": "opinionated linting and formatting for projects",
4
- "keywords": [
5
- "cli",
6
- "eslint",
7
- "eslint-config"
8
- ],
9
- "version": "0.3.7",
10
- "license": "MIT",
3
+ "version": "0.4.0-next.1",
11
4
  "type": "module",
5
+ "description": "opinionated linting and formatting for projects",
12
6
  "repository": {
13
7
  "type": "git",
14
8
  "url": "https://github.com/jycouet/kitql",
15
9
  "directory": "packages/eslint-config",
16
10
  "homepage": "https://github.com/jycouet/kitql/tree/main/packages/eslint-config"
17
11
  },
12
+ "license": "MIT",
18
13
  "bin": {
19
14
  "kitql-lint": "./cmd.js"
20
15
  },
21
- "main": "index.cjs",
16
+ "main": "eslint.config.js",
17
+ "files": [
18
+ ".prettierrc.cjs",
19
+ "cmd.js",
20
+ "cmd.sh",
21
+ "eslint.config.js",
22
+ "eslint.config.d.ts"
23
+ ],
24
+ "keywords": [
25
+ "cli",
26
+ "eslint",
27
+ "eslint-config"
28
+ ],
29
+ "peerDependencies": {
30
+ "prettier": "^3.3.3"
31
+ },
22
32
  "dependencies": {
23
- "@theguild/eslint-config": "^0.11.1",
24
- "@theguild/prettier-config": "2.0.2",
25
- "@typescript-eslint/eslint-plugin": "7.7.0",
26
- "@typescript-eslint/parser": "7.7.0",
27
- "@vue/compiler-sfc": "3.4.7",
28
- "commander": "^12.0.0",
29
- "eslint": "8.57.0",
30
- "eslint-config-prettier": "9.1.0",
33
+ "@eslint/js": "^9.10.0",
34
+ "@theguild/prettier-config": "2.0.7",
35
+ "@types/eslint": "9.6.1",
36
+ "commander": "12.1.0",
37
+ "eslint": "9.10.0",
31
38
  "eslint-plugin-svelte": "2.43.0",
32
- "eslint-plugin-unused-imports": "3.2.0",
33
- "prettier": "3.2.4",
34
- "prettier-plugin-sh": "0.14.0",
35
- "prettier-plugin-svelte": "3.2.2",
36
- "prettier-plugin-tailwindcss": "0.5.7",
37
- "svelte": "4.2.0",
38
- "typescript": "5.4.2",
39
+ "eslint-plugin-unused-imports": "^4.1.3",
40
+ "globals": "15.9.0",
41
+ "prettier": "3.3.3",
42
+ "prettier-plugin-svelte": "3.2.6",
43
+ "prettier-plugin-tailwindcss": "0.6.6",
44
+ "typescript-eslint": "8.5.0",
39
45
  "@kitql/helpers": "0.8.10"
40
46
  },
41
- "sideEffects": false,
42
47
  "publishConfig": {
43
48
  "access": "public"
44
49
  },
45
- "files": [
46
- "index.cjs",
47
- "cmd.sh",
48
- "cmd.js",
49
- ".eslintrc.cjs",
50
- ".prettierrc.cjs"
51
- ],
50
+ "sideEffects": false,
52
51
  "scripts": {
53
- "lint": "node ./cmd.js --verbose -p none",
54
52
  "format": "node ./cmd.js -f",
55
- "lint:example": "kitql-lint",
56
- "format:example": "kitql-lint --format"
53
+ "format:example": "kitql-lint --format",
54
+ "lint": "node ./cmd.js --verbose -p none",
55
+ "lint:example": "kitql-lint"
57
56
  }
58
57
  }
package/index.cjs DELETED
@@ -1,52 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- parser: '@typescript-eslint/parser',
4
- extends: [
5
- // '@theguild',
6
- // '@theguild/eslint-config/mdx',
7
- '@theguild/eslint-config/json',
8
- '@theguild/eslint-config/yml',
9
- 'eslint:recommended',
10
- 'plugin:@typescript-eslint/recommended',
11
- 'prettier',
12
- 'plugin:svelte/recommended',
13
- ],
14
- plugins: ['unused-imports', 'svelte', '@typescript-eslint'],
15
- rules: {
16
- 'no-console': ['error', { allow: ['info', 'warn', 'error', 'time', 'timeEnd', 'dir'] }],
17
- 'unused-imports/no-unused-imports': 'error',
18
- '@typescript-eslint/no-unused-vars': [
19
- 'warn',
20
- {
21
- argsIgnorePattern: '^_',
22
- varsIgnorePattern: '^_',
23
- caughtErrorsIgnorePattern: '^_',
24
- },
25
- ],
26
- 'no-empty': ['error', { allowEmptyCatch: true }],
27
- '@typescript-eslint/ban-ts-ignore': 'off',
28
- '@typescript-eslint/ban-ts-comment': 'off',
29
- '@typescript-eslint/no-explicit-any': 'off',
30
- '@typescript-eslint/no-non-null-assertion': 'off',
31
- '@typescript-eslint/no-unused-expressions': 'off',
32
- },
33
- overrides: [
34
- {
35
- files: ['*.svelte'],
36
- parser: 'svelte-eslint-parser',
37
- parserOptions: {
38
- parser: '@typescript-eslint/parser',
39
- },
40
- },
41
- ],
42
- ignorePatterns: ['*.md'],
43
- parserOptions: {
44
- sourceType: 'module',
45
- ecmaVersion: 2020,
46
- },
47
- env: {
48
- browser: true,
49
- es2017: true,
50
- node: true,
51
- },
52
- }