@kitql/eslint-config 0.1.1 → 0.3.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/.prettierrc.cjs +21 -2
- package/cmd.js +60 -6
- package/package.json +5 -6
package/.prettierrc.cjs
CHANGED
|
@@ -3,7 +3,26 @@ const { plugins, ...prettierConfig } = require('@theguild/prettier-config')
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
...prettierConfig,
|
|
5
5
|
semi: false,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
arrowParens: 'always',
|
|
7
|
+
plugins: [
|
|
8
|
+
...plugins,
|
|
9
|
+
'prettier-plugin-svelte',
|
|
10
|
+
'prettier-plugin-tailwindcss', // MUST come last
|
|
11
|
+
],
|
|
12
|
+
importOrderParserPlugins: ['typescript', 'decorators-legacy'],
|
|
13
|
+
importOrder: [
|
|
14
|
+
'<THIRD_PARTY_MODULES>',
|
|
15
|
+
'',
|
|
16
|
+
'^(\\$houdini)(.*)$', // special
|
|
17
|
+
'^(remult)(.*)$', // special
|
|
18
|
+
'^(@kitql)(.*)$', // special
|
|
19
|
+
'',
|
|
20
|
+
'^(\\$env)(.*)$', // special sveltekit
|
|
21
|
+
'^(\\$app)(.*)$', // special sveltekit
|
|
22
|
+
'',
|
|
23
|
+
'^(\\$)(.*)$', // Aliases
|
|
24
|
+
'',
|
|
25
|
+
'^[./]', // inside
|
|
26
|
+
],
|
|
8
27
|
importOrderSeparation: true,
|
|
9
28
|
}
|
package/cmd.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Log, red } from '@kitql/helpers'
|
|
3
2
|
import { spawn, spawnSync } from 'child_process'
|
|
4
|
-
import { program, Option } from 'commander'
|
|
5
3
|
import fs from 'fs'
|
|
4
|
+
import { Option, program } from 'commander'
|
|
5
|
+
|
|
6
|
+
import { Log, red } from '@kitql/helpers'
|
|
6
7
|
|
|
7
8
|
const log = new Log('kitql-lint')
|
|
8
9
|
|
|
9
10
|
program.addOption(new Option('-f, --format', 'format'))
|
|
10
11
|
program.addOption(new Option('-g, --glob <type>', 'file/dir/glob (. by default)', '.'))
|
|
12
|
+
program.addOption(new Option('--verbose', 'add more logs', false))
|
|
11
13
|
|
|
12
14
|
program.parse(process.argv)
|
|
13
15
|
const options_cli = program.opts()
|
|
14
16
|
|
|
15
|
-
const findFileOrUp = fileName => {
|
|
17
|
+
const findFileOrUp = (fileName) => {
|
|
16
18
|
// Find file recursively 4 levels max up
|
|
17
19
|
for (let i = 0; i < 4; i++) {
|
|
18
20
|
try {
|
|
@@ -34,6 +36,7 @@ let pathPrettierCjs = findFileOrUp('.prettierrc.cjs')
|
|
|
34
36
|
|
|
35
37
|
const format = options_cli.format ?? false
|
|
36
38
|
const glob = options_cli.glob ?? '.'
|
|
39
|
+
const verbose = options_cli.verbose ?? false
|
|
37
40
|
|
|
38
41
|
// First prettier
|
|
39
42
|
const cmdPrettier =
|
|
@@ -47,6 +50,10 @@ const cmdPrettier =
|
|
|
47
50
|
`${format ? ' --write' : ''}` +
|
|
48
51
|
// exec
|
|
49
52
|
` ${glob}`
|
|
53
|
+
|
|
54
|
+
if (verbose) {
|
|
55
|
+
log.info(cmdPrettier)
|
|
56
|
+
}
|
|
50
57
|
let result_prettier = spawn(cmdPrettier, {
|
|
51
58
|
shell: true,
|
|
52
59
|
cwd: process.cwd(),
|
|
@@ -56,7 +63,7 @@ let result_prettier = spawn(cmdPrettier, {
|
|
|
56
63
|
// let's not log anything when we are formating prettier
|
|
57
64
|
if (!format) {
|
|
58
65
|
const logPrettier = new Log('kitql-lint prettier')
|
|
59
|
-
result_prettier.stdout.on('data', data => {
|
|
66
|
+
result_prettier.stdout.on('data', (data) => {
|
|
60
67
|
logPrettier.error(
|
|
61
68
|
data
|
|
62
69
|
.toString()
|
|
@@ -65,8 +72,19 @@ if (!format) {
|
|
|
65
72
|
)
|
|
66
73
|
})
|
|
67
74
|
}
|
|
75
|
+
if (format && verbose) {
|
|
76
|
+
const logPrettier = new Log('kitql-lint prettier')
|
|
77
|
+
result_prettier.stdout.on('data', (data) => {
|
|
78
|
+
logPrettier.success(
|
|
79
|
+
data
|
|
80
|
+
.toString()
|
|
81
|
+
// rmv the last \n if any
|
|
82
|
+
.replace(/\n$/, ''),
|
|
83
|
+
)
|
|
84
|
+
})
|
|
85
|
+
}
|
|
68
86
|
|
|
69
|
-
|
|
87
|
+
function esLintRun(code) {
|
|
70
88
|
// Then eslint
|
|
71
89
|
const cmdEsLint =
|
|
72
90
|
`eslint` +
|
|
@@ -77,7 +95,9 @@ result_prettier.on('close', code => {
|
|
|
77
95
|
// exec
|
|
78
96
|
` ${glob}`
|
|
79
97
|
|
|
80
|
-
|
|
98
|
+
if (verbose) {
|
|
99
|
+
log.info(cmdEsLint)
|
|
100
|
+
}
|
|
81
101
|
|
|
82
102
|
let result_eslint = spawnSync(cmdEsLint, {
|
|
83
103
|
shell: true,
|
|
@@ -94,4 +114,38 @@ result_prettier.on('close', code => {
|
|
|
94
114
|
}
|
|
95
115
|
|
|
96
116
|
process.exit(code || result_eslint.status)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
result_prettier.stdout.on('end', (data) => {
|
|
120
|
+
if (verbose) {
|
|
121
|
+
log.info(`end`, data)
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
result_prettier.stdout.on('error', (data) => {
|
|
125
|
+
if (verbose) {
|
|
126
|
+
log.info(`error`, data)
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
result_prettier.stdout.on('pause', (data) => {
|
|
130
|
+
if (verbose) {
|
|
131
|
+
log.info(`pause`, data)
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
result_prettier.stdout.on('readable', (data) => {
|
|
135
|
+
if (verbose) {
|
|
136
|
+
log.info(`readable`, data)
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
result_prettier.stdout.on('resume', (data) => {
|
|
140
|
+
if (verbose) {
|
|
141
|
+
log.info(`resume`, data)
|
|
142
|
+
}
|
|
143
|
+
esLintRun(0)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
result_prettier.on('close', (data) => {
|
|
147
|
+
if (verbose) {
|
|
148
|
+
log.info(`close`, data)
|
|
149
|
+
}
|
|
150
|
+
esLintRun(data)
|
|
97
151
|
})
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"eslint",
|
|
7
7
|
"eslint-config"
|
|
8
8
|
],
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.3.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"repository": {
|
|
@@ -24,17 +24,16 @@
|
|
|
24
24
|
"@kitql/helpers": "0.8.8",
|
|
25
25
|
"@theguild/eslint-config": "^0.11.1",
|
|
26
26
|
"@theguild/prettier-config": "2.0.2",
|
|
27
|
-
"@
|
|
28
|
-
"@typescript-eslint/
|
|
29
|
-
"@typescript-eslint/parser": "6.18.1",
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "6.20.0",
|
|
28
|
+
"@typescript-eslint/parser": "6.20.0",
|
|
30
29
|
"@vue/compiler-sfc": "3.4.7",
|
|
31
30
|
"commander": "^11.1.0",
|
|
32
31
|
"eslint": "8.56.0",
|
|
33
32
|
"eslint-config-prettier": "9.1.0",
|
|
34
33
|
"eslint-plugin-svelte": "2.35.0",
|
|
35
34
|
"eslint-plugin-unused-imports": "3.0.0",
|
|
36
|
-
"prettier": "3.
|
|
37
|
-
"prettier-plugin-sh": "0.
|
|
35
|
+
"prettier": "3.2.4",
|
|
36
|
+
"prettier-plugin-sh": "0.14.0",
|
|
38
37
|
"prettier-plugin-svelte": "3.1.0",
|
|
39
38
|
"prettier-plugin-tailwindcss": "0.5.7",
|
|
40
39
|
"svelte": "4.2.0",
|