@huangjunsen/encode-fe-lint 1.0.7 → 1.0.8

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.
@@ -108,10 +108,27 @@ exports.default = async (options) => {
108
108
  if (!disableNpmInstall) {
109
109
  log_1.default.info(`Step ${++step}. 安装依赖`);
110
110
  const npm = await npm_type_1.default;
111
- const depsToInstall = [constants_1.PKG_NAME];
112
- if (config.eslintType && config.eslintType.startsWith('custom:')) {
113
- const customPkg = config.eslintType.replace('custom:', '');
114
- depsToInstall.push(customPkg);
111
+ const depsToInstall = [
112
+ constants_1.PKG_NAME,
113
+ '@huangjunsen/commitlint-config',
114
+ ];
115
+ if (config.enableESLint !== false) {
116
+ if (config.eslintType && config.eslintType.startsWith('custom:')) {
117
+ const customPkg = config.eslintType.replace('custom:', '');
118
+ depsToInstall.push(customPkg);
119
+ }
120
+ else {
121
+ depsToInstall.push('@huangjunsen/eslint-config');
122
+ }
123
+ }
124
+ if (config.enableStylelint) {
125
+ depsToInstall.push('@huangjunsen/stylelint-config');
126
+ }
127
+ if (config.enablePrettier) {
128
+ depsToInstall.push('@huangjunsen/prettier-config');
129
+ }
130
+ if (config.enableMarkdownlint) {
131
+ depsToInstall.push('@huangjunsen/markdownlint-config');
115
132
  }
116
133
  cross_spawn_1.default.sync(npm, ['i', '-D', ...depsToInstall], { stdio: 'inherit', cwd });
117
134
  log_1.default.success(`Step ${step}. 安装依赖成功 :D`);
@@ -14,7 +14,10 @@ exports.default = async (options) => {
14
14
  return fs_extra_1.default.existsSync(localPath) ? require(localPath) : {};
15
15
  };
16
16
  const pkg = readConfigFile('package.json');
17
- const config = scanConfig || readConfigFile(`${constants_1.PKG_NAME}.config.js`);
17
+ const configName = constants_1.PKG_NAME.split('/').pop() || constants_1.PKG_NAME;
18
+ const config = scanConfig ||
19
+ readConfigFile(`${configName}.config.js`) ||
20
+ readConfigFile(`${constants_1.PKG_NAME}.config.js`);
18
21
  const runErrors = [];
19
22
  let results = [];
20
23
  if (fix && config.enablePrettier !== false) {
package/lib/cli.js CHANGED
@@ -80,9 +80,16 @@ commander_1.program
80
80
  type = 'warn';
81
81
  }
82
82
  checking[type]();
83
- if (results.length > 0)
83
+ if (results.length > 0) {
84
84
  (0, print_report_1.default)(results, false);
85
- runErrors.forEach((e) => console.log(e));
85
+ }
86
+ else if (runErrors.length === 0) {
87
+ log_1.default.success('代码规范扫描完成,未发现任何规范问题!:D');
88
+ }
89
+ if (runErrors.length > 0) {
90
+ log_1.default.warn('扫描过程中发生以下异常:');
91
+ runErrors.forEach((e) => console.log(e));
92
+ }
86
93
  });
87
94
  commander_1.program
88
95
  .command('commit-msg-scan')
@@ -15,6 +15,7 @@ function getStylelintConfig(opts, pkg, config) {
15
15
  const lintConfig = {
16
16
  fix: Boolean(fix),
17
17
  allowEmptyInput: true,
18
+ configBasedir: cwd,
18
19
  };
19
20
  if (config.stylelintOptions) {
20
21
  Object.assign(lintConfig, config.stylelintOptions);
package/package.json CHANGED
@@ -1,8 +1,17 @@
1
1
  {
2
2
  "name": "@huangjunsen/encode-fe-lint",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "前端编码规范工程化标准脚手架",
5
+ "bin": "./lib/cli.js",
5
6
  "main": "./lib/index.js",
7
+ "scripts": {
8
+ "dev": "npm run copyfiles && tsc -w",
9
+ "build": "rm -rf lib && npm run copyfiles && tsc",
10
+ "copyfiles": "copyfiles -a -u 1 \"src/config/**\" lib",
11
+ "test": "npm run build && jest",
12
+ "coverage": "nyc jest --silent --forceExit",
13
+ "prepublishOnly": "npm run test"
14
+ },
6
15
  "files": [
7
16
  "lib/",
8
17
  "README.md"
@@ -38,6 +47,11 @@
38
47
  "@babel/eslint-parser": "^7.24.1",
39
48
  "@babel/preset-react": "^7.24.1",
40
49
  "@commitlint/cli": "^16.3.0",
50
+ "@huangjunsen/commitlint-config": "workspace:^",
51
+ "@huangjunsen/eslint-config": "workspace:^",
52
+ "@huangjunsen/markdownlint-config": "workspace:^",
53
+ "@huangjunsen/prettier-config": "workspace:^",
54
+ "@huangjunsen/stylelint-config": "workspace:^",
41
55
  "@typescript-eslint/eslint-plugin": "^5.62.0",
42
56
  "@typescript-eslint/parser": "^5.62.0",
43
57
  "chalk": "^4.1.2",
@@ -72,12 +86,7 @@
72
86
  "stylelint-scss": "^4.7.0",
73
87
  "terminal-link": "^2.1.1",
74
88
  "text-table": "^0.2.0",
75
- "vue-eslint-parser": "^7.11.0",
76
- "@huangjunsen/markdownlint-config": "^1.0.0",
77
- "@huangjunsen/eslint-config": "^1.0.1",
78
- "@huangjunsen/prettier-config": "^1.0.1",
79
- "@huangjunsen/commitlint-config": "^1.0.1",
80
- "@huangjunsen/stylelint-config": "^1.0.0"
89
+ "vue-eslint-parser": "^7.11.0"
81
90
  },
82
91
  "author": "Huangjunsen <951434130@qq.com>",
83
92
  "homepage": "https://github.com/Huang-junsen/js-encode-fe-spec#readme",
@@ -88,15 +97,5 @@
88
97
  },
89
98
  "bugs": {
90
99
  "url": "https://github.com/Huang-junsen/js-encode-fe-spec/issues"
91
- },
92
- "scripts": {
93
- "dev": "npm run copyfiles && tsc -w",
94
- "build": "rm -rf lib && npm run copyfiles && tsc",
95
- "copyfiles": "copyfiles -a -u 1 \"src/config/**\" lib",
96
- "test": "npm run build && jest",
97
- "coverage": "nyc jest --silent --forceExit"
98
- },
99
- "bin": {
100
- "encode-fe-lint": "./lib/cli.js"
101
100
  }
102
- }
101
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 黄俊森
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.