@huangjunsen/encode-fe-lint 1.0.5 → 1.0.7
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/lib/actions/init.d.ts +3 -3
- package/lib/actions/init.js +151 -223
- package/lib/actions/scan.d.ts +3 -3
- package/lib/actions/scan.js +60 -137
- package/lib/actions/update.d.ts +2 -2
- package/lib/actions/update.js +51 -112
- package/lib/cli.d.ts +2 -2
- package/lib/cli.js +145 -230
- package/lib/config/_editorconfig.ejs +13 -13
- package/lib/config/_eslintignore.ejs +9 -9
- package/lib/config/_eslintrc.js.ejs +21 -3
- package/lib/config/_markdownlint.json.ejs +1 -1
- package/lib/config/_markdownlintignore.ejs +5 -5
- package/lib/config/_prettierrc.js.ejs +3 -8
- package/lib/config/_stylelintignore.ejs +5 -5
- package/lib/config/_stylelintrc.js.ejs +5 -5
- package/lib/config/_vscode/extensions.json.ejs +7 -7
- package/lib/config/_vscode/settings.json.ejs +55 -54
- package/lib/config/commitlint.config.js.ejs +3 -3
- package/lib/config/encode-fe-lint.config.js.ejs +6 -6
- package/lib/config/eslint.config.mjs.ejs +5 -0
- package/lib/index.d.ts +5 -5
- package/lib/index.js +36 -93
- package/lib/lints/eslint/doEslint.d.ts +6 -6
- package/lib/lints/eslint/doEslint.js +44 -80
- package/lib/lints/eslint/formatESLintResults.d.ts +3 -3
- package/lib/lints/eslint/formatESLintResults.js +28 -39
- package/lib/lints/eslint/getESLintConfig.d.ts +3 -3
- package/lib/lints/eslint/getESLintConfig.js +43 -67
- package/lib/lints/eslint/getESLintConfigType.d.ts +2 -2
- package/lib/lints/eslint/getESLintConfigType.js +23 -26
- package/lib/lints/eslint/index.d.ts +3 -3
- package/lib/lints/eslint/index.js +19 -19
- package/lib/lints/index.d.ts +4 -4
- package/lib/lints/index.js +20 -20
- package/lib/lints/markdownlint/doMarkdownlint.d.ts +6 -6
- package/lib/lints/markdownlint/doMarkdownlint.js +52 -119
- package/lib/lints/markdownlint/formatMarkdownlintResults.d.ts +3 -3
- package/lib/lints/markdownlint/formatMarkdownlintResults.js +35 -39
- package/lib/lints/markdownlint/getMarkdownlintConfig.d.ts +7 -7
- package/lib/lints/markdownlint/getMarkdownlintConfig.js +31 -31
- package/lib/lints/markdownlint/index.d.ts +3 -3
- package/lib/lints/markdownlint/index.js +19 -19
- package/lib/lints/prettier/doPrettier.d.ts +4 -4
- package/lib/lints/prettier/doPrettier.js +32 -106
- package/lib/lints/prettier/index.d.ts +1 -1
- package/lib/lints/prettier/index.js +17 -17
- package/lib/lints/stylelint/doStylelint.d.ts +5 -5
- package/lib/lints/stylelint/doStylelint.js +31 -86
- package/lib/lints/stylelint/formatStylelintResults.d.ts +3 -3
- package/lib/lints/stylelint/formatStylelintResults.js +38 -39
- package/lib/lints/stylelint/getStylelintConfig.d.ts +3 -3
- package/lib/lints/stylelint/getStylelintConfig.js +36 -36
- package/lib/lints/stylelint/getStylelintDocUrl.d.ts +1 -1
- package/lib/lints/stylelint/getStylelintDocUrl.js +13 -13
- package/lib/lints/stylelint/index.d.ts +3 -3
- package/lib/lints/stylelint/index.js +19 -19
- package/lib/types/index.d.ts +73 -73
- package/lib/types/index.js +2 -2
- package/lib/utils/conflict-resolve.d.ts +3 -3
- package/lib/utils/conflict-resolve.js +95 -175
- package/lib/utils/constants.d.ts +18 -18
- package/lib/utils/constants.js +104 -133
- package/lib/utils/generate-template.d.ts +2 -2
- package/lib/utils/generate-template.js +53 -99
- package/lib/utils/git.d.ts +3 -3
- package/lib/utils/git.js +44 -105
- package/lib/utils/log.d.ts +8 -8
- package/lib/utils/log.js +25 -25
- package/lib/utils/npm-type.d.ts +2 -2
- package/lib/utils/npm-type.js +10 -10
- package/lib/utils/print-report.d.ts +3 -3
- package/lib/utils/print-report.js +86 -109
- package/package.json +13 -8
- package/lib/utils/update.d.ts +0 -2
- package/lib/utils/update.js +0 -112
|
@@ -1,67 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
errorOnUnmatchedPattern: false,
|
|
45
|
-
};
|
|
46
|
-
if (config.eslintOptions) {
|
|
47
|
-
Object.assign(lintConfig, config.eslintOptions);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
var lintConfigFiles = glob_1.default.sync('.eslintrc?(.@(js|yaml|yml|json))', { cwd: cwd });
|
|
51
|
-
if (lintConfigFiles.length === 0 && !pkg.eslintConfig) {
|
|
52
|
-
lintConfig.resolvePluginsRelativeTo = path_1.default.resolve(__dirname, '../../');
|
|
53
|
-
lintConfig.useEslintrc = false;
|
|
54
|
-
lintConfig.baseConfig = {
|
|
55
|
-
extends: __spreadArray([
|
|
56
|
-
(0, getESLintConfigType_1.getESLintConfigType)(cwd, pkg)
|
|
57
|
-
], __read((config.enablePrettier ? ['prettier'] : [])), false),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
var lintIgnoreFile = path_1.default.resolve(cwd, '.eslintignore');
|
|
61
|
-
if (!fs_extra_1.default.existsSync(lintIgnoreFile) && !pkg.eslintIgnore) {
|
|
62
|
-
lintConfig.ignorePath = path_1.default.resolve(__dirname, '../config/_eslintignore.ejs');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return lintConfig;
|
|
66
|
-
}
|
|
67
|
-
exports.getESLintConfig = getESLintConfig;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getESLintConfig = void 0;
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const glob_1 = __importDefault(require("glob"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const constants_1 = require("../../utils/constants");
|
|
11
|
+
const getESLintConfigType_1 = require("./getESLintConfigType");
|
|
12
|
+
function getESLintConfig(opts, pkg, config) {
|
|
13
|
+
const { cwd, fix, ignore } = opts;
|
|
14
|
+
const lintConfig = {
|
|
15
|
+
cwd,
|
|
16
|
+
fix,
|
|
17
|
+
ignore,
|
|
18
|
+
extensions: constants_1.ESLINT_FILE_EXT,
|
|
19
|
+
errorOnUnmatchedPattern: false,
|
|
20
|
+
};
|
|
21
|
+
if (config.eslintOptions) {
|
|
22
|
+
Object.assign(lintConfig, config.eslintOptions);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const lintConfigFiles = glob_1.default.sync('.eslintrc?(.@(js|yaml|yml|json))', { cwd });
|
|
26
|
+
if (lintConfigFiles.length === 0 && !pkg.eslintConfig) {
|
|
27
|
+
lintConfig.resolvePluginsRelativeTo = path_1.default.resolve(__dirname, '../../');
|
|
28
|
+
lintConfig.useEslintrc = false;
|
|
29
|
+
lintConfig.baseConfig = {
|
|
30
|
+
extends: [
|
|
31
|
+
(0, getESLintConfigType_1.getESLintConfigType)(cwd, pkg),
|
|
32
|
+
...(config.enablePrettier ? ['prettier'] : []),
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const lintIgnoreFile = path_1.default.resolve(cwd, '.eslintignore');
|
|
37
|
+
if (!fs_extra_1.default.existsSync(lintIgnoreFile) && !pkg.eslintIgnore) {
|
|
38
|
+
lintConfig.ignorePath = path_1.default.resolve(__dirname, '../config/_eslintignore.ejs');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return lintConfig;
|
|
42
|
+
}
|
|
43
|
+
exports.getESLintConfig = getESLintConfig;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { PKG } from '../../types';
|
|
2
|
-
export declare function getESLintConfigType(cwd: string, pkg: PKG): string;
|
|
1
|
+
import type { PKG } from '../../types';
|
|
2
|
+
export declare function getESLintConfigType(cwd: string, pkg: PKG): string;
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getESLintConfigType = void 0;
|
|
7
|
-
|
|
8
|
-
function getESLintConfigType(cwd, pkg) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (reactFiles.length > 0 || dependencies.some(
|
|
16
|
-
dsl = 'react';
|
|
17
|
-
}
|
|
18
|
-
else if (vueFiles.length > 0 || dependencies.some(
|
|
19
|
-
dsl = 'vue';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return ('@huangjunsen/eslint-config/' + "".concat(language, "/").concat(dsl).replace(/\/$/, '/index').replace(/^\//, ''));
|
|
25
|
-
}
|
|
26
|
-
exports.getESLintConfigType = getESLintConfigType;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getESLintConfigType = void 0;
|
|
7
|
+
const glob_1 = __importDefault(require("glob"));
|
|
8
|
+
function getESLintConfigType(cwd, pkg) {
|
|
9
|
+
const tsFiles = glob_1.default.sync('./!(node_modules)/**/*.@(ts|tsx)', { cwd });
|
|
10
|
+
const reactFiles = glob_1.default.sync('./!(node_modules)/**/*.@(jsx|tsx)', { cwd });
|
|
11
|
+
const vueFiles = glob_1.default.sync('./!(node_modules)/**/*.vue', { cwd });
|
|
12
|
+
const dependencies = Object.keys(pkg.dependencies || {});
|
|
13
|
+
const language = tsFiles.length > 0 ? 'typescript' : '';
|
|
14
|
+
let dsl = '';
|
|
15
|
+
if (reactFiles.length > 0 || dependencies.some((name) => /^react(-|$)/.test(name))) {
|
|
16
|
+
dsl = 'react';
|
|
17
|
+
}
|
|
18
|
+
else if (vueFiles.length > 0 || dependencies.some((name) => /^vue(-|$)/.test(name))) {
|
|
19
|
+
dsl = 'vue';
|
|
20
|
+
}
|
|
21
|
+
return ('@huangjunsen/eslint-config/' + `${language}/${dsl}`.replace(/\/$/, '/index').replace(/^\//, ''));
|
|
22
|
+
}
|
|
23
|
+
exports.getESLintConfigType = getESLintConfigType;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './getESLintConfig';
|
|
2
|
-
export * from './formatESLintResults';
|
|
3
|
-
export * from './doEslint';
|
|
1
|
+
export * from './getESLintConfig';
|
|
2
|
+
export * from './formatESLintResults';
|
|
3
|
+
export * from './doEslint';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./getESLintConfig"), exports);
|
|
18
|
-
__exportStar(require("./formatESLintResults"), exports);
|
|
19
|
-
__exportStar(require("./doEslint"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./getESLintConfig"), exports);
|
|
18
|
+
__exportStar(require("./formatESLintResults"), exports);
|
|
19
|
+
__exportStar(require("./doEslint"), exports);
|
package/lib/lints/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './eslint';
|
|
2
|
-
export * from './markdownlint';
|
|
3
|
-
export * from './stylelint';
|
|
4
|
-
export * from './prettier';
|
|
1
|
+
export * from './eslint';
|
|
2
|
+
export * from './markdownlint';
|
|
3
|
+
export * from './stylelint';
|
|
4
|
+
export * from './prettier';
|
package/lib/lints/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./eslint"), exports);
|
|
18
|
-
__exportStar(require("./markdownlint"), exports);
|
|
19
|
-
__exportStar(require("./stylelint"), exports);
|
|
20
|
-
__exportStar(require("./prettier"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./eslint"), exports);
|
|
18
|
+
__exportStar(require("./markdownlint"), exports);
|
|
19
|
+
__exportStar(require("./stylelint"), exports);
|
|
20
|
+
__exportStar(require("./prettier"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Config, PKG, ScanOptions } from '../../types';
|
|
2
|
-
export interface DoMarkdownlintOptions extends ScanOptions {
|
|
3
|
-
pkg: PKG;
|
|
4
|
-
config?: Config;
|
|
5
|
-
}
|
|
6
|
-
export declare function doMarkdownlint(options: DoMarkdownlintOptions): Promise<import("../../types").ScanResult[]>;
|
|
1
|
+
import { Config, PKG, ScanOptions } from '../../types';
|
|
2
|
+
export interface DoMarkdownlintOptions extends ScanOptions {
|
|
3
|
+
pkg: PKG;
|
|
4
|
+
config?: Config;
|
|
5
|
+
}
|
|
6
|
+
export declare function doMarkdownlint(options: DoMarkdownlintOptions): Promise<import("../../types").ScanResult[]>;
|
|
@@ -1,119 +1,52 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
exports.doMarkdownlint = void 0;
|
|
54
|
-
var fast_glob_1 = __importDefault(require("fast-glob"));
|
|
55
|
-
var fs_extra_1 = require("fs-extra");
|
|
56
|
-
var markdownlint_1 = __importDefault(require("markdownlint"));
|
|
57
|
-
var markdownlint_rule_helpers_1 = __importDefault(require("markdownlint-rule-helpers"));
|
|
58
|
-
var path_1 = require("path");
|
|
59
|
-
var constants_1 = require("../../utils/constants");
|
|
60
|
-
var formatMarkdownlintResults_1 = require("./formatMarkdownlintResults");
|
|
61
|
-
var getMarkdownlintConfig_1 = require("./getMarkdownlintConfig");
|
|
62
|
-
function doMarkdownlint(options) {
|
|
63
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
var files, pattern, results, file;
|
|
65
|
-
return __generator(this, function (_a) {
|
|
66
|
-
switch (_a.label) {
|
|
67
|
-
case 0:
|
|
68
|
-
if (!options.files) return [3, 1];
|
|
69
|
-
files = options.files.filter(function (name) { return constants_1.MARKDOWN_LINT_FILE_EXT.includes((0, path_1.extname)(name)); });
|
|
70
|
-
return [3, 3];
|
|
71
|
-
case 1:
|
|
72
|
-
pattern = (0, path_1.join)(options.include, "**/*.{".concat(constants_1.MARKDOWN_LINT_FILE_EXT.map(function (t) { return t.replace(/^\./, ''); }).join(','), "}"));
|
|
73
|
-
return [4, (0, fast_glob_1.default)(pattern, {
|
|
74
|
-
cwd: options.cwd,
|
|
75
|
-
ignore: constants_1.MARKDOWN_LINT_IGNORE_PATTERN,
|
|
76
|
-
})];
|
|
77
|
-
case 2:
|
|
78
|
-
files = _a.sent();
|
|
79
|
-
_a.label = 3;
|
|
80
|
-
case 3: return [4, markdownlint_1.default.promises.markdownlint(__assign(__assign({}, (0, getMarkdownlintConfig_1.getMarkdownlintConfig)(options, options.pkg, options.config)), { files: files }))];
|
|
81
|
-
case 4:
|
|
82
|
-
results = _a.sent();
|
|
83
|
-
if (!options.fix) return [3, 6];
|
|
84
|
-
return [4, Promise.all(Object.keys(results).map(function (filename) { return formatMarkdownFile(filename, results[filename]); }))];
|
|
85
|
-
case 5:
|
|
86
|
-
_a.sent();
|
|
87
|
-
for (file in results) {
|
|
88
|
-
if (!Object.prototype.hasOwnProperty.call(results, file))
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
_a.label = 6;
|
|
92
|
-
case 6: return [2, (0, formatMarkdownlintResults_1.formatMarkdownlintResults)(results, options.quiet)];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
exports.doMarkdownlint = doMarkdownlint;
|
|
98
|
-
function formatMarkdownFile(filename, errors) {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
-
var fixes, originalText, fixedText;
|
|
101
|
-
return __generator(this, function (_a) {
|
|
102
|
-
switch (_a.label) {
|
|
103
|
-
case 0:
|
|
104
|
-
fixes = errors === null || errors === void 0 ? void 0 : errors.filter(function (error) { return error.fixInfo; });
|
|
105
|
-
if (!((fixes === null || fixes === void 0 ? void 0 : fixes.length) > 0)) return [3, 3];
|
|
106
|
-
return [4, (0, fs_extra_1.readFile)(filename, 'utf8')];
|
|
107
|
-
case 1:
|
|
108
|
-
originalText = _a.sent();
|
|
109
|
-
fixedText = markdownlint_rule_helpers_1.default.applyFixes(originalText, fixes);
|
|
110
|
-
if (!(originalText !== fixedText)) return [3, 3];
|
|
111
|
-
return [4, (0, fs_extra_1.writeFile)(filename, fixedText, 'utf8')];
|
|
112
|
-
case 2:
|
|
113
|
-
_a.sent();
|
|
114
|
-
return [2, errors.filter(function (error) { return !error.fixInfo; })];
|
|
115
|
-
case 3: return [2, errors];
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.doMarkdownlint = void 0;
|
|
7
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
8
|
+
const fs_extra_1 = require("fs-extra");
|
|
9
|
+
const markdownlint_1 = __importDefault(require("markdownlint"));
|
|
10
|
+
const markdownlint_rule_helpers_1 = __importDefault(require("markdownlint-rule-helpers"));
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
const constants_1 = require("../../utils/constants");
|
|
13
|
+
const formatMarkdownlintResults_1 = require("./formatMarkdownlintResults");
|
|
14
|
+
const getMarkdownlintConfig_1 = require("./getMarkdownlintConfig");
|
|
15
|
+
async function doMarkdownlint(options) {
|
|
16
|
+
let files;
|
|
17
|
+
if (options.files) {
|
|
18
|
+
files = options.files.filter((name) => constants_1.MARKDOWN_LINT_FILE_EXT.includes((0, path_1.extname)(name)));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const pattern = (0, path_1.join)(options.include, `**/*.{${constants_1.MARKDOWN_LINT_FILE_EXT.map((t) => t.replace(/^\./, '')).join(',')}}`);
|
|
22
|
+
files = await (0, fast_glob_1.default)(pattern, {
|
|
23
|
+
cwd: options.cwd,
|
|
24
|
+
ignore: constants_1.MARKDOWN_LINT_IGNORE_PATTERN,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const results = await markdownlint_1.default.promises.markdownlint({
|
|
28
|
+
...(0, getMarkdownlintConfig_1.getMarkdownlintConfig)(options, options.pkg, options.config),
|
|
29
|
+
files,
|
|
30
|
+
});
|
|
31
|
+
if (options.fix) {
|
|
32
|
+
await Promise.all(Object.keys(results).map((filename) => formatMarkdownFile(filename, results[filename])));
|
|
33
|
+
for (const file in results) {
|
|
34
|
+
if (!Object.prototype.hasOwnProperty.call(results, file))
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return (0, formatMarkdownlintResults_1.formatMarkdownlintResults)(results, options.quiet);
|
|
39
|
+
}
|
|
40
|
+
exports.doMarkdownlint = doMarkdownlint;
|
|
41
|
+
async function formatMarkdownFile(filename, errors) {
|
|
42
|
+
const fixes = errors?.filter((error) => error.fixInfo);
|
|
43
|
+
if (fixes?.length > 0) {
|
|
44
|
+
const originalText = await (0, fs_extra_1.readFile)(filename, 'utf8');
|
|
45
|
+
const fixedText = markdownlint_rule_helpers_1.default.applyFixes(originalText, fixes);
|
|
46
|
+
if (originalText !== fixedText) {
|
|
47
|
+
await (0, fs_extra_1.writeFile)(filename, fixedText, 'utf8');
|
|
48
|
+
return errors.filter((error) => !error.fixInfo);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return errors;
|
|
52
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import markdownlint from 'markdownlint';
|
|
2
|
-
import type { ScanResult } from '../../types';
|
|
3
|
-
export declare function formatMarkdownlintResults(results: markdownlint.LintResults, quiet: boolean): ScanResult[];
|
|
1
|
+
import markdownlint from 'markdownlint';
|
|
2
|
+
import type { ScanResult } from '../../types';
|
|
3
|
+
export declare function formatMarkdownlintResults(results: markdownlint.LintResults, quiet: boolean): ScanResult[];
|
|
@@ -1,39 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatMarkdownlintResults = void 0;
|
|
4
|
-
function formatMarkdownlintResults(results, quiet) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (!Object.prototype.hasOwnProperty.call(results, file) || quiet)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
return parsedResults;
|
|
38
|
-
}
|
|
39
|
-
exports.formatMarkdownlintResults = formatMarkdownlintResults;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatMarkdownlintResults = void 0;
|
|
4
|
+
function formatMarkdownlintResults(results, quiet) {
|
|
5
|
+
const parsedResults = [];
|
|
6
|
+
for (const file in results) {
|
|
7
|
+
if (!Object.prototype.hasOwnProperty.call(results, file) || quiet)
|
|
8
|
+
continue;
|
|
9
|
+
let warningCount = 0;
|
|
10
|
+
let fixableWarningCount = 0;
|
|
11
|
+
const messages = results[file].map(({ lineNumber, ruleNames, ruleDescription, ruleInformation, errorRange, fixInfo }) => {
|
|
12
|
+
if (fixInfo)
|
|
13
|
+
fixableWarningCount++;
|
|
14
|
+
warningCount++;
|
|
15
|
+
return {
|
|
16
|
+
line: lineNumber,
|
|
17
|
+
column: Array.isArray(errorRange) ? errorRange[0] : 1,
|
|
18
|
+
rule: ruleNames[0],
|
|
19
|
+
url: ruleInformation,
|
|
20
|
+
message: ruleDescription,
|
|
21
|
+
errored: false,
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
parsedResults.push({
|
|
25
|
+
filePath: file,
|
|
26
|
+
messages,
|
|
27
|
+
errorCount: 0,
|
|
28
|
+
warningCount,
|
|
29
|
+
fixableErrorCount: 0,
|
|
30
|
+
fixableWarningCount,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return parsedResults;
|
|
34
|
+
}
|
|
35
|
+
exports.formatMarkdownlintResults = formatMarkdownlintResults;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import markdownLint from 'markdownlint';
|
|
2
|
-
import type { ScanOptions, PKG, Config } from '../../types';
|
|
3
|
-
type LintOptions = markdownLint.Options & {
|
|
4
|
-
fix?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare function getMarkdownlintConfig(opts: ScanOptions, pkg: PKG, config: Config): LintOptions;
|
|
7
|
-
export {};
|
|
1
|
+
import markdownLint from 'markdownlint';
|
|
2
|
+
import type { ScanOptions, PKG, Config } from '../../types';
|
|
3
|
+
type LintOptions = markdownLint.Options & {
|
|
4
|
+
fix?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function getMarkdownlintConfig(opts: ScanOptions, pkg: PKG, config: Config): LintOptions;
|
|
7
|
+
export {};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getMarkdownlintConfig = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function getMarkdownlintConfig(opts, pkg, config) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
fix: Boolean(opts.fix),
|
|
15
|
-
resultVersion: 3,
|
|
16
|
-
};
|
|
17
|
-
if (config.markdownlintOptions) {
|
|
18
|
-
Object.assign(lintConfig, config.markdownlintOptions);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
|
|
22
|
-
if (lintConfigFiles.length === 0) {
|
|
23
|
-
lintConfig.config = markdownlint_config_1.default;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
lintConfig.config = markdownlint_1.default.readConfigSync(path_1.default.resolve(cwd, lintConfigFiles[0]));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return lintConfig;
|
|
30
|
-
}
|
|
31
|
-
exports.getMarkdownlintConfig = getMarkdownlintConfig;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getMarkdownlintConfig = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const glob_1 = __importDefault(require("glob"));
|
|
9
|
+
const markdownlint_1 = __importDefault(require("markdownlint"));
|
|
10
|
+
const markdownlint_config_1 = __importDefault(require("@huangjunsen/markdownlint-config"));
|
|
11
|
+
function getMarkdownlintConfig(opts, pkg, config) {
|
|
12
|
+
const { cwd } = opts;
|
|
13
|
+
const lintConfig = {
|
|
14
|
+
fix: Boolean(opts.fix),
|
|
15
|
+
resultVersion: 3,
|
|
16
|
+
};
|
|
17
|
+
if (config.markdownlintOptions) {
|
|
18
|
+
Object.assign(lintConfig, config.markdownlintOptions);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const lintConfigFiles = glob_1.default.sync('.markdownlint(.@(yaml|yml|json))', { cwd });
|
|
22
|
+
if (lintConfigFiles.length === 0) {
|
|
23
|
+
lintConfig.config = markdownlint_config_1.default;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
lintConfig.config = markdownlint_1.default.readConfigSync(path_1.default.resolve(cwd, lintConfigFiles[0]));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return lintConfig;
|
|
30
|
+
}
|
|
31
|
+
exports.getMarkdownlintConfig = getMarkdownlintConfig;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './getMarkdownlintConfig';
|
|
2
|
-
export * from './formatMarkdownlintResults';
|
|
3
|
-
export * from './doMarkdownlint';
|
|
1
|
+
export * from './getMarkdownlintConfig';
|
|
2
|
+
export * from './formatMarkdownlintResults';
|
|
3
|
+
export * from './doMarkdownlint';
|