@cloudpss/lint-staged-config 1.4.0 → 1.4.1

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 (2) hide show
  1. package/index.js +16 -14
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -7,13 +7,14 @@ const eslintCli = new (require('eslint').ESLint)({});
7
7
 
8
8
  const DEBUG = (process.env['DEBUG'] ?? '').includes('lint-staged-config');
9
9
 
10
- /** @type {readonly string[]} */
10
+ /** @type {ReadonlyArray<string>} */
11
11
  const prettierSupportedExt = prettierSupportInfo.languages.flatMap((l) => l.extensions ?? []);
12
- /** @type {readonly string[]} */
12
+ /** @type {ReadonlyArray<string>} */
13
13
  const prettierSupportedFilename = prettierSupportInfo.languages.flatMap((l) => l.filenames ?? []);
14
14
 
15
15
  /**
16
- * @param {string} f
16
+ * 检查文件是否是 eslint 支持的文件
17
+ * @param {string} f 文件路径
17
18
  */
18
19
  const isEslintFile = async (f) => {
19
20
  const ext = path.extname(f);
@@ -21,13 +22,14 @@ const isEslintFile = async (f) => {
21
22
  return !(await eslintCli.isPathIgnored(f));
22
23
  };
23
24
 
25
+ /**
26
+ * 检查文件是否是 stylelint 支持的文件
27
+ * @param {string} f 文件路径
28
+ */
24
29
  const isStylelintFile = (() => {
25
30
  try {
26
31
  require.resolve('stylelint');
27
- /**
28
- * @param {string} f
29
- */
30
- return (f) => {
32
+ return (/** @type {string} */ f) => {
31
33
  const ext = path.extname(f);
32
34
  if (!ext || !['.css', '.scss', '.sass'].includes(ext)) return false;
33
35
  return true;
@@ -38,17 +40,20 @@ const isStylelintFile = (() => {
38
40
  })();
39
41
 
40
42
  /**
41
- * @param {string[]} files
42
- * @param {string[]} commands
43
+ * 生成命令
44
+ * @param {string[]} files 文件列表
45
+ * @param {string[]} commands 命令列表
43
46
  */
44
47
  function makeCommands(files, commands) {
45
48
  if (files.length === 0) return [];
46
49
  const fileLine = ` -- '${files.join(`' '`)}'`;
47
50
  return commands.map((c) => c + fileLine);
48
51
  }
52
+
49
53
  /**
50
- * @param {(files: string[]) => (string[] | Promise<string[]>)} impl
51
- * @returns {(files: string[]) => Promise<string[]>}
54
+ * 包装处理函数
55
+ * @param {(files: string[]) => (string[] | Promise<string[]>)} impl 处理函数
56
+ * @returns {(files: string[]) => Promise<string[]>} 包装后的处理函数
52
57
  */
53
58
  function handler(impl) {
54
59
  return async (files) => {
@@ -65,9 +70,6 @@ function handler(impl) {
65
70
  }
66
71
 
67
72
  module.exports = {
68
- /**
69
- * @param {string[]} files
70
- */
71
73
  '*': handler(async (files) => {
72
74
  const commands = [];
73
75
  const eslintFiles = [];
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "license": "MIT",
4
4
  "homepage": "https://cloudpss.net/",
5
5
  "repository": "https://codeup.aliyun.com/cloudpss/code-quality.git",
6
- "version": "1.4.0",
6
+ "version": "1.4.1",
7
7
  "main": "./index.js",
8
8
  "devDependencies": {
9
9
  "@types/eslint": "^8.37.0",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "eslint": "^8.39.0",
14
- "lint-staged": "^13.2.1",
14
+ "lint-staged": "^13.2.2",
15
15
  "prettier": "^2.8.8"
16
16
  }
17
17
  }