@coko/lint 3.0.0-alpha.3 → 3.0.0-alpha.31

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/src/logger.mjs ADDED
@@ -0,0 +1,21 @@
1
+ /* eslint-disable no-console */
2
+
3
+ import chalk from 'chalk'
4
+
5
+ const pre = chalk.cyan.underline('[coko lint]')
6
+ const primary = chalk.cyan
7
+ const error = chalk.red
8
+
9
+ const logger = {
10
+ error: str => {
11
+ console.log(error(`${pre} ${str}`))
12
+ },
13
+ info: str => {
14
+ console.log(primary(`${pre} ${str}`))
15
+ },
16
+ newLine: () => {
17
+ console.log('')
18
+ },
19
+ }
20
+
21
+ export default logger
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  arrowParens: 'avoid',
3
3
  semi: false,
4
4
  singleQuote: true,
@@ -0,0 +1,17 @@
1
+ export default {
2
+ extends: ['stylelint-config-standard'],
3
+ overrides: [
4
+ {
5
+ files: ['**/*.{js,jsx,mjs,mts,ts,tsx}'],
6
+ customSyntax: 'postcss-styled-syntax',
7
+ },
8
+ ],
9
+ rules: {
10
+ 'comment-empty-line-before': null,
11
+ 'declaration-empty-line-before': null,
12
+ 'declaration-block-no-duplicate-properties': true,
13
+ 'declaration-no-important': true,
14
+ 'no-descending-specificity': null,
15
+ 'no-empty-source': null,
16
+ },
17
+ }
@@ -1,26 +0,0 @@
1
- // const confusingBrowserGlobals = require('confusing-browser-globals')
2
-
3
- export default {
4
- rules: {
5
- // disallow specific globals
6
- 'no-restricted-globals': [
7
- 'error',
8
- {
9
- name: 'isFinite',
10
- message:
11
- 'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
12
- },
13
- {
14
- name: 'isNaN',
15
- message:
16
- 'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
17
- },
18
- ]
19
- .concat
20
- // confusingBrowserGlobals.map(g => ({
21
- // name: g,
22
- // message: `Use window.${g} instead. https://github.com/facebook/create-react-app/blob/HEAD/packages/confusing-browser-globals/README.md`,
23
- // })),
24
- (),
25
- },
26
- }
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
- }