@coko/lint 3.0.0-alpha.9 → 3.0.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/CHANGELOG.md CHANGED
@@ -2,6 +2,198 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [3.0.0](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-beta.0...v3.0.0) (2026-06-10)
6
+
7
+ ## [3.0.0-beta.0](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.37...v3.0.0-beta.0) (2026-06-08)
8
+
9
+ ## [3.0.0-alpha.37](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.36...v3.0.0-alpha.37) (2026-05-05)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * **lintstaged:** fix extensions during lintstaged ([2241a37](https://gitlab.coko.foundation/cokoapps/lint/commit/2241a37a549ffd06cd54e97f05f78f50562b199d))
15
+
16
+ ## [3.0.0-alpha.36](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.35...v3.0.0-alpha.36) (2026-05-04)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **eslint:** fix cypress pattern and add browser globals to pattern ([5784998](https://gitlab.coko.foundation/cokoapps/lint/commit/57849987886257f769ec115d85570b3a27d5152f))
22
+
23
+ ## [3.0.0-alpha.35](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.34...v3.0.0-alpha.35) (2026-05-04)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * **eslint:** do not leak node rules in cypress folder ([553bd4a](https://gitlab.coko.foundation/cokoapps/lint/commit/553bd4a821a7b40e010224bc04fbbd5760c18a1a))
29
+
30
+ ## [3.0.0-alpha.34](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.33...v3.0.0-alpha.34) (2026-05-04)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * **eslint:** allow import/export in cypress files ([2fee5a0](https://gitlab.coko.foundation/cokoapps/lint/commit/2fee5a082394780076460ed5d8a68bfab9cd326a))
36
+
37
+ ## [3.0.0-alpha.33](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.32...v3.0.0-alpha.33) (2026-05-04)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * **eslint:** make sure server rules do not bleed into client ([2291bcd](https://gitlab.coko.foundation/cokoapps/lint/commit/2291bcd5073b1e5f3bad9efd08a15f1f1c9f098e))
43
+
44
+ ## [3.0.0-alpha.32](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.31...v3.0.0-alpha.32) (2026-05-04)
45
+
46
+
47
+ ### Bug Fixes
48
+
49
+ * **eslint:** add explicit sourcetype module for client js files ([c05d056](https://gitlab.coko.foundation/cokoapps/lint/commit/c05d0560a8fbfa2797eec257c1c06840b1f94641))
50
+
51
+ ## [3.0.0-alpha.31](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.30...v3.0.0-alpha.31) (2026-05-04)
52
+
53
+
54
+ ### Features
55
+
56
+ * **eslint:** more nuanced root config ([d8f7fc2](https://gitlab.coko.foundation/cokoapps/lint/commit/d8f7fc2fb9926bdfc92e66712b468827936efd48))
57
+
58
+ ## [3.0.0-alpha.30](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.29...v3.0.0-alpha.30) (2026-05-04)
59
+
60
+
61
+ ### Features
62
+
63
+ * allow passing path to the lint commands ([dd7a355](https://gitlab.coko.foundation/cokoapps/lint/commit/dd7a35561e0757f03d11d192f60b43834a63ce56))
64
+
65
+ ## [3.0.0-alpha.29](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.28...v3.0.0-alpha.29) (2026-04-29)
66
+
67
+
68
+ ### Features
69
+
70
+ * **eslint:** export root eslint config ([5b2c6d5](https://gitlab.coko.foundation/cokoapps/lint/commit/5b2c6d50377b40ad8b84b4188ac4fd35a226502a))
71
+
72
+ ## [3.0.0-alpha.28](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.27...v3.0.0-alpha.28) (2026-04-28)
73
+
74
+
75
+ ### Bug Fixes
76
+
77
+ * **eslint:** fix cz config issues on the client side ([11f92ed](https://gitlab.coko.foundation/cokoapps/lint/commit/11f92ed65f709a9e8a69012b91b5d8d0b72d0288))
78
+
79
+ ## [3.0.0-alpha.27](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.26...v3.0.0-alpha.27) (2026-04-27)
80
+
81
+
82
+ ### Bug Fixes
83
+
84
+ * **stylelint:** properly disable rule ([24c16b6](https://gitlab.coko.foundation/cokoapps/lint/commit/24c16b619d431f26c33d33268cb4f085a859cc1b))
85
+
86
+ ## [3.0.0-alpha.26](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.25...v3.0.0-alpha.26) (2026-04-27)
87
+
88
+
89
+ ### Features
90
+
91
+ * **stylelint:** allow empty source ([64eb3b8](https://gitlab.coko.foundation/cokoapps/lint/commit/64eb3b83e3a8200432e5e624b3458cf43328bbd3))
92
+
93
+ ## [3.0.0-alpha.25](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.24...v3.0.0-alpha.25) (2026-04-23)
94
+
95
+
96
+ ### Features
97
+
98
+ * **eslint:** add root config with cypress plugin ([6078f5b](https://gitlab.coko.foundation/cokoapps/lint/commit/6078f5bf6e451903738a8eda6f288b7f52ee3877))
99
+ * **eslint:** enable the eslint plugin promises config ([00a6f56](https://gitlab.coko.foundation/cokoapps/lint/commit/00a6f5644eb4f4c371577abdcf4e869383faae0d))
100
+ * **stylelint:** modern stylelint configuration ([9741171](https://gitlab.coko.foundation/cokoapps/lint/commit/974117104009e9b3a254b9539d8082198d68553c))
101
+
102
+ ## [3.0.0-alpha.24](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.23...v3.0.0-alpha.24) (2026-02-04)
103
+
104
+
105
+ ### Features
106
+
107
+ * **eslint:** add process to client globals ([4e12d2d](https://gitlab.coko.foundation/cokoapps/lint/commit/4e12d2d3c892636297516e6ca6c8afa24076d276))
108
+
109
+ ## [3.0.0-alpha.23](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.22...v3.0.0-alpha.23) (2026-02-03)
110
+
111
+
112
+ ### Bug Fixes
113
+
114
+ * fix position of react detect setting in object ([eb81055](https://gitlab.coko.foundation/cokoapps/lint/commit/eb81055ada1dd3f11cc161640491a93455c4e13f))
115
+
116
+ ## [3.0.0-alpha.22](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.21...v3.0.0-alpha.22) (2026-02-03)
117
+
118
+
119
+ ### Features
120
+
121
+ * **eslint:** detect react version ([3f5d4fe](https://gitlab.coko.foundation/cokoapps/lint/commit/3f5d4fe1c64fa0bd455d56f386ee646030b5917e))
122
+
123
+ ## [3.0.0-alpha.21](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.20...v3.0.0-alpha.21) (2026-01-26)
124
+
125
+
126
+ ### Bug Fixes
127
+
128
+ * **eslint:** no extensions for jsx/tsx files ([25ec578](https://gitlab.coko.foundation/cokoapps/lint/commit/25ec5782e79c2960a56d5416a995093148f90411))
129
+
130
+ ## [3.0.0-alpha.20](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.19...v3.0.0-alpha.20) (2026-01-26)
131
+
132
+
133
+ ### Bug Fixes
134
+
135
+ * **eslint:** export client config ([5d4df78](https://gitlab.coko.foundation/cokoapps/lint/commit/5d4df78d62005544afc2143e83ca951ddad07c56))
136
+
137
+ ## [3.0.0-alpha.19](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.18...v3.0.0-alpha.19) (2026-01-23)
138
+
139
+
140
+ ### Features
141
+
142
+ * **eslint:** add client config ([ac6878a](https://gitlab.coko.foundation/cokoapps/lint/commit/ac6878ae6f3934eccdb0d48c4a39331311fe6ce2))
143
+
144
+ ## [3.0.0-alpha.18](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.17...v3.0.0-alpha.18) (2026-01-20)
145
+
146
+
147
+ ### Bug Fixes
148
+
149
+ * fix commit command ([9934d20](https://gitlab.coko.foundation/cokoapps/lint/commit/9934d2075bfea115265400df4d6be864f1f8eed8))
150
+
151
+ ## [3.0.0-alpha.17](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.16...v3.0.0-alpha.17) (2026-01-20)
152
+
153
+
154
+ ### Features
155
+
156
+ * add lint-staged and commit commands ([dcff789](https://gitlab.coko.foundation/cokoapps/lint/commit/dcff78993000a4df6ef0e35f67057d5de05682d7))
157
+
158
+ ## [3.0.0-alpha.16](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.15...v3.0.0-alpha.16) (2026-01-19)
159
+
160
+
161
+ ### Bug Fixes
162
+
163
+ * include file extension for commitizen import ([3911856](https://gitlab.coko.foundation/cokoapps/lint/commit/3911856673e137136e1754563259c254f158a20d))
164
+
165
+ ## [3.0.0-alpha.15](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.14...v3.0.0-alpha.15) (2026-01-19)
166
+
167
+
168
+ ### Bug Fixes
169
+
170
+ * fix package.json index path ([4bac830](https://gitlab.coko.foundation/cokoapps/lint/commit/4bac8300f6a1e6e83544c61c9b8d8b2daa4451c9))
171
+
172
+ ## [3.0.0-alpha.14](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.13...v3.0.0-alpha.14) (2026-01-19)
173
+
174
+
175
+ ### Bug Fixes
176
+
177
+ * fix cli import of package.json ([c4325d2](https://gitlab.coko.foundation/cokoapps/lint/commit/c4325d2a7757b8dfac224d1edb7cc827df9ab12e))
178
+
179
+ ## [3.0.0-alpha.13](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.12...v3.0.0-alpha.13) (2026-01-19)
180
+
181
+
182
+ ### Bug Fixes
183
+
184
+ * fix cli path in package.json ([e7dae84](https://gitlab.coko.foundation/cokoapps/lint/commit/e7dae84139742c11bab104e0e7c4bece95964c50))
185
+
186
+ ## [3.0.0-alpha.12](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.11...v3.0.0-alpha.12) (2026-01-19)
187
+
188
+ ## [3.0.0-alpha.11](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.10...v3.0.0-alpha.11) (2026-01-19)
189
+
190
+ ## [3.0.0-alpha.10](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.9...v3.0.0-alpha.10) (2025-12-02)
191
+
192
+
193
+ ### Bug Fixes
194
+
195
+ * **eslint:** do not autofix vitest/no-focused-tests ([717897e](https://gitlab.coko.foundation/cokoapps/lint/commit/717897e1b072c651008c52ebddaf7df9cdbbdfb3))
196
+
5
197
  ## [3.0.0-alpha.9](https://gitlab.coko.foundation/cokoapps/lint/compare/v3.0.0-alpha.8...v3.0.0-alpha.9) (2025-12-01)
6
198
 
7
199
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coko/lint",
3
- "version": "3.0.0-alpha.9",
3
+ "version": "3.0.0",
4
4
  "description": "Linter configurations and dependencies for coko's projects",
5
5
  "keywords": [
6
6
  "lint",
@@ -14,17 +14,17 @@
14
14
  "license": "MIT",
15
15
  "author": "Yannis Barlas",
16
16
  "engines": {
17
- "node": "^22.16.0"
17
+ "node": ">= 22"
18
18
  },
19
19
  "main": "src/index.mjs",
20
20
  "bin": {
21
- "coko-lint": "./src/cli.js"
21
+ "coko-lint": "./src/cli.mjs"
22
22
  },
23
23
  "files": [
24
24
  "src"
25
25
  ],
26
26
  "scripts": {
27
- "cz": "git-cz",
27
+ "commit": "./src/cli.mjs commit --skip-stylelint",
28
28
  "prepare": "husky install",
29
29
  "release": "standard-version",
30
30
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -35,52 +35,37 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@babel/core": "^7.28.4",
39
- "@babel/eslint-parser": "^7.28.4",
40
- "@babel/preset-react": "^7.27.1",
41
- "@commitlint/cli": "^20.1.0",
42
- "@commitlint/config-conventional": "^20.0.0",
43
- "@eslint/eslintrc": "^3.3.1",
44
- "@eslint/js": "^9.38.0",
45
- "@vitest/eslint-plugin": "^1.4.1",
46
- "commander": "^14.0.1",
38
+ "@eslint/js": "^9.39.2",
39
+ "@vitest/eslint-plugin": "^1.6.6",
40
+ "chalk": "^5.6.2",
41
+ "commander": "^14.0.2",
47
42
  "commitizen": "^4.3.1",
48
- "conventional-commit-types": "^3.0.0",
49
- "cz-conventional-changelog": "^3.3.0",
50
- "cz-customizable": "^6.9.0",
51
- "eslint": "^9.38.0",
52
- "eslint-config-airbnb": "^19.0.4",
43
+ "confusing-browser-globals": "^1.0.11",
44
+ "cz-customizable": "^7.5.1",
45
+ "eslint": "^9.39.2",
53
46
  "eslint-config-prettier": "^10.1.8",
54
- "eslint-config-standard": "^17.1.0",
55
- "eslint-config-standard-react": "^13.0.0",
56
47
  "eslint-import-resolver-typescript": "^4.4.4",
57
- "eslint-plugin-cypress": "^5.2.0",
48
+ "eslint-plugin-cypress": "^5.2.1",
58
49
  "eslint-plugin-import": "^2.32.0",
59
- "eslint-plugin-jest": "^29.0.1",
60
50
  "eslint-plugin-jsx-a11y": "^6.10.2",
61
- "eslint-plugin-n": "^17.23.1",
51
+ "eslint-plugin-n": "^17.23.2",
62
52
  "eslint-plugin-promise": "^7.2.1",
63
53
  "eslint-plugin-react": "^7.37.5",
64
- "eslint-plugin-react-hooks": "^7.0.0",
65
- "eslint-plugin-workspaces": "^0.11.0",
66
- "globals": "^16.4.0",
67
- "husky": "^9.1.7",
68
- "lint-staged": "^16.2.6",
69
- "longest": "^2.0.1",
54
+ "eslint-plugin-react-hooks": "^7.0.1",
55
+ "eslint-plugin-workspaces": "^0.11.1",
56
+ "globals": "^17.0.0",
57
+ "lint-staged": "^16.2.7",
70
58
  "postcss": "^8.5.6",
71
- "postcss-scss": "^4.0.9",
72
- "prettier": "^3.6.2",
73
- "right-pad": "^1.0.1",
74
- "stylelint": "^16.25.0",
75
- "stylelint-config-standard-scss": "^16.0.0",
76
- "stylelint-config-styled-components": "^0.1.1",
77
- "stylelint-order": "^7.0.0",
78
- "stylelint-processor-styled-components": "^1.10.0",
59
+ "postcss-styled-syntax": "^0.7.1",
60
+ "prettier": "^3.8.0",
61
+ "stylelint": "^17.1.1",
62
+ "stylelint-config-standard": "^40.0.0",
79
63
  "typescript": "^5.9.3",
80
- "typescript-eslint": "^8.46.2"
64
+ "typescript-eslint": "^8.53.0"
81
65
  },
82
66
  "devDependencies": {
83
- "standard-version": "^9.5.0"
67
+ "standard-version": "^9.5.0",
68
+ "styled-components": "^6.3.8"
84
69
  },
85
70
  "publishConfig": {
86
71
  "access": "public"
package/src/cli.mjs ADDED
@@ -0,0 +1,207 @@
1
+ #!/usr/bin/env node
2
+
3
+ /* eslint-disable n/no-process-exit */
4
+
5
+ import { execSync } from 'node:child_process'
6
+ import path from 'node:path'
7
+ import { createRequire } from 'node:module'
8
+
9
+ import { program } from 'commander'
10
+ import lintStagedLib from 'lint-staged'
11
+
12
+ import pkg from '../package.json' with { type: 'json' }
13
+ import logger from './logger.mjs'
14
+
15
+ const require = createRequire(import.meta.url)
16
+ const cz = require('commitizen/dist/cli/git-cz')
17
+ const czPath = require.resolve('commitizen')
18
+
19
+ const ESLINT = 'ESLint'
20
+ const STYLELINT = 'Stylelint'
21
+ const PRETTIER = 'Prettier'
22
+ const filler = '>>>> '
23
+
24
+ // #region actions
25
+ const printVersion = () => {
26
+ logger.info(`Coko lint version: ${program.version()}\n`)
27
+ }
28
+
29
+ const runCommand = (name, command, isSubprocess) => {
30
+ logger.info(`\n${filler}Running ${name}...`)
31
+
32
+ try {
33
+ execSync(command, { stdio: 'inherit' })
34
+ } catch (error) {
35
+ logger.error(`Error running ${name}: ${error.message}`)
36
+
37
+ if (isSubprocess) {
38
+ throw new Error()
39
+ } else {
40
+ process.exit(1)
41
+ }
42
+ }
43
+ }
44
+
45
+ const runSubprocess = (fn, name, skip) => {
46
+ try {
47
+ if (skip) {
48
+ logger.info(`\n${filler}Skipping ${name}...`)
49
+ return
50
+ }
51
+
52
+ fn(true)
53
+ } catch {
54
+ throw new Error()
55
+ }
56
+ }
57
+
58
+ const runESLint = (isSubprocess, targetPath) => {
59
+ const target = targetPath ?? process.cwd()
60
+ const command = `npx eslint ${target}`
61
+ runCommand(ESLINT, command, isSubprocess)
62
+ }
63
+
64
+ const runStylelint = (isSubprocess, targetPath) => {
65
+ const target = targetPath
66
+ ? `"${targetPath}/**/*.{js,jsx,ts,tsx,css}"`
67
+ : `"${process.cwd()}/**/*.{js,jsx,ts,tsx,css}"`
68
+ const command = `npx stylelint ${target}`
69
+ runCommand(STYLELINT, command, isSubprocess)
70
+ }
71
+
72
+ const runPrettier = (isSubprocess, targetPath) => {
73
+ const target = targetPath ?? process.cwd()
74
+ const command = `npx prettier --check ${target}`
75
+ runCommand(PRETTIER, command, isSubprocess)
76
+ }
77
+
78
+ const runAll = (options = {}) => {
79
+ let hasErrors = false
80
+
81
+ const processes = [
82
+ [runESLint, ESLINT, options.skipEslint],
83
+ [runStylelint, STYLELINT, options.skipStylelint],
84
+ [runPrettier, PRETTIER, options.skipPrettier],
85
+ ]
86
+
87
+ for (const process of processes) {
88
+ try {
89
+ runSubprocess(...process)
90
+ } catch {
91
+ hasErrors = true
92
+ }
93
+ }
94
+
95
+ if (hasErrors) {
96
+ logger.error('\nError: Linting checks did not pass!')
97
+ process.exit(1)
98
+ }
99
+
100
+ logger.info(`\nLinting checks successfully passed`)
101
+ }
102
+
103
+ const lintStaged = async options => {
104
+ const jsArray = ['eslint']
105
+ if (!options.skipStylelint) jsArray.push('stylelint')
106
+
107
+ const success = await lintStagedLib({
108
+ cwd: process.cwd(),
109
+ config: {
110
+ '*.{js,mjs,ts,mts,jsx,tsx}': jsArray,
111
+ '*.{js,ts,mjs,mts,jsx,tsx,graphql,json,yml,md,html}': [
112
+ 'prettier --check',
113
+ ],
114
+ },
115
+ })
116
+
117
+ logger.newLine()
118
+ if (!success) throw new Error('Lint staged failed!')
119
+ logger.info('Lint staged successfully completed')
120
+ }
121
+
122
+ const commit = async options => {
123
+ execSync('git add -A', { stdio: 'inherit' })
124
+ execSync('git status', { stdio: 'inherit' })
125
+
126
+ await lintStaged(options)
127
+ logger.newLine()
128
+
129
+ // filter out
130
+ // - the 'commit' command
131
+ // - the --skip-stylelint flag
132
+ // if we don't do this, cz will pass them onto git (which will throw)
133
+ process.argv = process.argv.slice(0, 2)
134
+
135
+ cz.bootstrap({
136
+ cliPath: path.join(czPath, '..', '..'),
137
+ })
138
+ }
139
+ // #endregion actions
140
+
141
+ program
142
+ .name('coko-lint')
143
+ .version(pkg.version)
144
+ .description("Coko's cli tool for running linters")
145
+
146
+ program
147
+ .command('eslint [path]')
148
+ .description('Run eslint command')
149
+ .action(targetPath => {
150
+ printVersion()
151
+ runESLint(false, targetPath)
152
+ })
153
+
154
+ program
155
+ .command('stylelint [path]')
156
+ .description('Run stylelint command')
157
+ .action(targetPath => {
158
+ printVersion()
159
+ runStylelint(false, targetPath)
160
+ })
161
+
162
+ program
163
+ .command('prettier [path]')
164
+ .description('Run prettier command')
165
+ .action(targetPath => {
166
+ printVersion()
167
+ runPrettier(false, targetPath)
168
+ })
169
+
170
+ program
171
+ .command('run')
172
+ .description('Run all commands (eslint, stylelint, prettier)')
173
+ .option('--skip-eslint', 'Skip eslint')
174
+ .option('--skip-stylelint', 'Skip stylelint')
175
+ .option('--skip-prettier', 'Skip prettier')
176
+ .action(options => {
177
+ printVersion()
178
+ runAll(options)
179
+ })
180
+
181
+ program
182
+ .command('lint-staged')
183
+ .description('Lint staged files')
184
+ .option('--skip-stylelint', 'Skip stylelint')
185
+ .action(async options => {
186
+ try {
187
+ printVersion()
188
+ await lintStaged(options)
189
+ } catch (e) {
190
+ throw new Error(e)
191
+ }
192
+ })
193
+
194
+ program
195
+ .command('commit')
196
+ .description('Launch interactive commit builder')
197
+ .option('--skip-stylelint', 'Skip stylelint')
198
+ .action(async options => {
199
+ try {
200
+ printVersion()
201
+ await commit(options)
202
+ } catch (e) {
203
+ throw new Error(e)
204
+ }
205
+ })
206
+
207
+ program.parse(process.argv)
package/src/commitizen.js CHANGED
@@ -1,15 +1,62 @@
1
- const longest = require('longest')
2
- const rightPad = require('right-pad')
3
- const conventionalCommitTypes = require('conventional-commit-types')
1
+ // https://github.com/commitizen/conventional-commit-types/blob/master/index.json
2
+ const types = {
3
+ feat: {
4
+ description: 'A new feature',
5
+ title: 'Features',
6
+ },
7
+ fix: {
8
+ description: 'A bug fix',
9
+ title: 'Bug Fixes',
10
+ },
11
+ docs: {
12
+ description: 'Documentation only changes',
13
+ title: 'Documentation',
14
+ },
15
+ style: {
16
+ description:
17
+ 'Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)',
18
+ title: 'Styles',
19
+ },
20
+ refactor: {
21
+ description: 'A code change that neither fixes a bug nor adds a feature',
22
+ title: 'Code Refactoring',
23
+ },
24
+ perf: {
25
+ description: 'A code change that improves performance',
26
+ title: 'Performance Improvements',
27
+ },
28
+ test: {
29
+ description: 'Adding missing tests or correcting existing tests',
30
+ title: 'Tests',
31
+ },
32
+ build: {
33
+ description:
34
+ 'Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)',
35
+ title: 'Builds',
36
+ },
37
+ ci: {
38
+ description:
39
+ 'Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)',
40
+ title: 'Continuous Integrations',
41
+ },
42
+ chore: {
43
+ description: "Other changes that don't modify src or test files",
44
+ title: 'Chores',
45
+ },
46
+ revert: {
47
+ description: 'Reverts a previous commit',
48
+ title: 'Reverts',
49
+ },
50
+ }
4
51
 
5
- // Borrowed from cz-conventional-changelog
6
- const { types } = conventionalCommitTypes
7
- const length = longest(Object.keys(types)).length + 1
52
+ const maxLength = Math.max(Object.keys(types).map(key => key.length)) + 1
8
53
 
9
54
  const choices = Object.keys(types).map(key => {
10
55
  const type = types[key]
56
+ const name = `${`${key}:`.padEnd(maxLength)} ${type.description}`
57
+
11
58
  return {
12
- name: `${rightPad(`${key}:`, length)} ${type.description}`,
59
+ name,
13
60
  value: key,
14
61
  }
15
62
  })