@coko/lint 3.0.0-alpha.3 → 3.0.0-alpha.30
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/CHANGELOG.md +176 -0
- package/package.json +25 -38
- package/src/cli.mjs +205 -0
- package/src/commitizen.js +54 -7
- package/src/eslint.bak.js +102 -102
- package/src/eslint.mjs +155 -90
- package/src/index.mjs +15 -5
- package/src/{lintstaged.js → lintstaged.mjs} +1 -1
- package/src/logger.mjs +21 -0
- package/src/{prettier.js → prettier.mjs} +1 -1
- package/src/stylelint.mjs +17 -0
- package/src/airbnb/variables.mjs +0 -26
- package/src/cli.js +0 -131
- package/src/stylelint.js +0 -27
package/src/cli.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-console */
|
|
4
|
-
|
|
5
|
-
const { program } = require('commander')
|
|
6
|
-
const { execSync } = require('child_process')
|
|
7
|
-
|
|
8
|
-
const pkg = require('../package.json')
|
|
9
|
-
|
|
10
|
-
const ESLINT = 'ESLint'
|
|
11
|
-
const STYLELINT = 'Stylelint'
|
|
12
|
-
const PRETTIER = 'Prettier'
|
|
13
|
-
const filler = '>>>> '
|
|
14
|
-
|
|
15
|
-
// #region actions
|
|
16
|
-
const printVersion = () => {
|
|
17
|
-
console.log(`Coko lint version: ${program.version()}`)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const runCommand = (name, command, isSubprocess) => {
|
|
21
|
-
console.log(`\n${filler}Running ${name}...`)
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
execSync(command, { stdio: 'inherit' })
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.error(`Error running ${name}: ${error.message}`)
|
|
27
|
-
|
|
28
|
-
if (isSubprocess) {
|
|
29
|
-
throw new Error()
|
|
30
|
-
} else {
|
|
31
|
-
process.exit(1)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const runSubprocess = (fn, name, skip) => {
|
|
37
|
-
try {
|
|
38
|
-
if (skip) {
|
|
39
|
-
console.log(`\n${filler}Skipping ${name}...`)
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
fn(true)
|
|
44
|
-
} catch {
|
|
45
|
-
throw new Error()
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const runESLint = isSubprocess => {
|
|
50
|
-
const command = `npx eslint ${process.cwd()}`
|
|
51
|
-
runCommand(ESLINT, command, isSubprocess)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const runStylelint = isSubprocess => {
|
|
55
|
-
const command = `npx stylelint "${process.cwd()}/**/*.js"`
|
|
56
|
-
runCommand(STYLELINT, command, isSubprocess)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const runPrettier = isSubprocess => {
|
|
60
|
-
const command = `npx prettier --check ${process.cwd()}`
|
|
61
|
-
runCommand(PRETTIER, command, isSubprocess)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const runAll = (options = {}) => {
|
|
65
|
-
let hasErrors = false
|
|
66
|
-
|
|
67
|
-
const processes = [
|
|
68
|
-
[runESLint, ESLINT, options.skipEslint],
|
|
69
|
-
[runStylelint, STYLELINT, options.skipStylelint],
|
|
70
|
-
[runPrettier, PRETTIER, options.skipPrettier],
|
|
71
|
-
]
|
|
72
|
-
|
|
73
|
-
/* eslint-disable-next-line no-restricted-syntax */
|
|
74
|
-
for (const process of processes) {
|
|
75
|
-
try {
|
|
76
|
-
runSubprocess(...process)
|
|
77
|
-
} catch {
|
|
78
|
-
hasErrors = true
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (hasErrors) {
|
|
83
|
-
console.error('\nError: Linting checks did not pass!')
|
|
84
|
-
process.exit(1)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
console.log(`\nLinting checks successfully passed`)
|
|
88
|
-
}
|
|
89
|
-
// #endregion actions
|
|
90
|
-
|
|
91
|
-
program
|
|
92
|
-
.name('coko-lint')
|
|
93
|
-
.version(pkg.version)
|
|
94
|
-
.description("Coko's cli tool for running linters")
|
|
95
|
-
|
|
96
|
-
program
|
|
97
|
-
.command('eslint')
|
|
98
|
-
.description('Run eslint command')
|
|
99
|
-
.action(() => {
|
|
100
|
-
printVersion()
|
|
101
|
-
runESLint()
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
program
|
|
105
|
-
.command('stylelint')
|
|
106
|
-
.description('Run stylelint command')
|
|
107
|
-
.action(() => {
|
|
108
|
-
printVersion()
|
|
109
|
-
runStylelint()
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
program
|
|
113
|
-
.command('prettier')
|
|
114
|
-
.description('Run prettier command')
|
|
115
|
-
.action(() => {
|
|
116
|
-
printVersion()
|
|
117
|
-
runPrettier()
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
program
|
|
121
|
-
.command('run')
|
|
122
|
-
.description('Run all commands (eslint, stylelint, prettier)')
|
|
123
|
-
.option('--skip-eslint', 'Skip eslint')
|
|
124
|
-
.option('--skip-stylelint', 'Skip stylelint')
|
|
125
|
-
.option('--skip-prettier', 'Skip prettier')
|
|
126
|
-
.action(options => {
|
|
127
|
-
printVersion()
|
|
128
|
-
runAll(options)
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
program.parse(process.argv)
|
package/src/stylelint.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
extends: [
|
|
3
|
-
'stylelint-config-standard-scss',
|
|
4
|
-
'stylelint-config-styled-components',
|
|
5
|
-
],
|
|
6
|
-
customSyntax: 'postcss-scss',
|
|
7
|
-
ignoreFiles: ['_build'],
|
|
8
|
-
plugins: ['stylelint-order'],
|
|
9
|
-
processors: ['stylelint-processor-styled-components'],
|
|
10
|
-
rules: {
|
|
11
|
-
'declaration-no-important': true,
|
|
12
|
-
// 'order/order': ['declarations', 'rules', 'at-rules'],
|
|
13
|
-
'order/order': null,
|
|
14
|
-
'order/properties-alphabetical-order': true,
|
|
15
|
-
'rule-empty-line-before': [
|
|
16
|
-
'always',
|
|
17
|
-
{ ignore: ['first-nested', 'after-comment'] },
|
|
18
|
-
],
|
|
19
|
-
|
|
20
|
-
'value-keyword-case': null,
|
|
21
|
-
'comment-empty-line-before': null,
|
|
22
|
-
'declaration-colon-newline-after': null,
|
|
23
|
-
'keyframes-name-pattern': null,
|
|
24
|
-
'declaration-empty-line-before': null,
|
|
25
|
-
'selector-class-pattern': null,
|
|
26
|
-
},
|
|
27
|
-
}
|