@kitql/eslint-config 0.2.0 → 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.
Files changed (3) hide show
  1. package/.prettierrc.cjs +21 -2
  2. package/cmd.js +57 -4
  3. package/package.json +1 -1
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
- plugins: [...plugins, 'prettier-plugin-svelte'],
7
- importOrder: ['<THIRD_PARTY_MODULES>', '', '^(\\$houdini|@kitql|remult|\\$)(.*)$', '', '^[./]'],
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
@@ -9,11 +9,12 @@ const log = new Log('kitql-lint')
9
9
 
10
10
  program.addOption(new Option('-f, --format', 'format'))
11
11
  program.addOption(new Option('-g, --glob <type>', 'file/dir/glob (. by default)', '.'))
12
+ program.addOption(new Option('--verbose', 'add more logs', false))
12
13
 
13
14
  program.parse(process.argv)
14
15
  const options_cli = program.opts()
15
16
 
16
- const findFileOrUp = fileName => {
17
+ const findFileOrUp = (fileName) => {
17
18
  // Find file recursively 4 levels max up
18
19
  for (let i = 0; i < 4; i++) {
19
20
  try {
@@ -35,6 +36,7 @@ let pathPrettierCjs = findFileOrUp('.prettierrc.cjs')
35
36
 
36
37
  const format = options_cli.format ?? false
37
38
  const glob = options_cli.glob ?? '.'
39
+ const verbose = options_cli.verbose ?? false
38
40
 
39
41
  // First prettier
40
42
  const cmdPrettier =
@@ -48,6 +50,10 @@ const cmdPrettier =
48
50
  `${format ? ' --write' : ''}` +
49
51
  // exec
50
52
  ` ${glob}`
53
+
54
+ if (verbose) {
55
+ log.info(cmdPrettier)
56
+ }
51
57
  let result_prettier = spawn(cmdPrettier, {
52
58
  shell: true,
53
59
  cwd: process.cwd(),
@@ -57,7 +63,7 @@ let result_prettier = spawn(cmdPrettier, {
57
63
  // let's not log anything when we are formating prettier
58
64
  if (!format) {
59
65
  const logPrettier = new Log('kitql-lint prettier')
60
- result_prettier.stdout.on('data', data => {
66
+ result_prettier.stdout.on('data', (data) => {
61
67
  logPrettier.error(
62
68
  data
63
69
  .toString()
@@ -66,8 +72,19 @@ if (!format) {
66
72
  )
67
73
  })
68
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
+ }
69
86
 
70
- result_prettier.on('close', code => {
87
+ function esLintRun(code) {
71
88
  // Then eslint
72
89
  const cmdEsLint =
73
90
  `eslint` +
@@ -78,7 +95,9 @@ result_prettier.on('close', code => {
78
95
  // exec
79
96
  ` ${glob}`
80
97
 
81
- // log.info(cmdEsLint)
98
+ if (verbose) {
99
+ log.info(cmdEsLint)
100
+ }
82
101
 
83
102
  let result_eslint = spawnSync(cmdEsLint, {
84
103
  shell: true,
@@ -95,4 +114,38 @@ result_prettier.on('close', code => {
95
114
  }
96
115
 
97
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)
98
151
  })
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "eslint",
7
7
  "eslint-config"
8
8
  ],
9
- "version": "0.2.0",
9
+ "version": "0.3.0",
10
10
  "license": "MIT",
11
11
  "type": "module",
12
12
  "repository": {