Skip to content
This repository was archived by the owner on May 16, 2020. It is now read-only.

Commit 044fc06

Browse files
feat(atlauncher-scripts): add in markdown linting
1 parent 392970c commit 044fc06

File tree

5 files changed

+235
-17
lines changed

5 files changed

+235
-17
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"default": true,
3+
"ul-style": { "style": "asterisk" },
4+
"ul-start-left": false,
5+
"ul-indent": 2,
6+
"no-multiple-blanks": { "maximum": 1 },
7+
"line-length": 120,
8+
"hr-style": { "style": "---" }
9+
}

packages/atlauncher-scripts/package-lock.json

Lines changed: 179 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/atlauncher-scripts/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545
"eslint-plugin-promise": "^3.6.0",
4646
"eslint-plugin-react": "^7.5.1",
4747
"is-windows": "^1.0.1",
48-
"jest": "^22.1.4"
48+
"jest": "^22.1.4",
49+
"markdownlint": "^0.7.0",
50+
"markdownlint-cli": "^0.6.0"
4951
},
5052
"engineStrict": true,
5153
"engines": {

packages/atlauncher-scripts/scripts/lint.js

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ process.on('unhandledRejection', (err) => {
1414

1515
(() => {
1616
const args = process.argv.slice(2);
17-
let toLint = 'all';
17+
let toLint = 'js';
1818
let debug = false;
1919
let watch = false;
2020
let commandBinToRun = 'eslint';
@@ -24,6 +24,8 @@ process.on('unhandledRejection', (err) => {
2424
args.forEach((arg) => {
2525
if (arg === 'js') {
2626
toLint = 'js';
27+
} else if (arg === 'md') {
28+
toLint = 'md';
2729
}
2830

2931
if (arg === '--watch') {
@@ -38,28 +40,41 @@ process.on('unhandledRejection', (err) => {
3840

3941
const processArguments = [];
4042

41-
if (!watch && (toLint === 'js' || toLint === 'all')) {
43+
if (toLint === 'js') {
44+
if (watch) {
45+
commandBinToRun = 'chokidar';
46+
processArguments.push([utils.getSourceCodeGlob('js'), '--initial', '-c npm run lint:js']);
47+
} else {
48+
const command = [
49+
'--config',
50+
utils.getRootFile('.eslintrc'),
51+
'--ignore-path',
52+
utils.getRootFile('.eslintignore'),
53+
];
54+
55+
if (debug) {
56+
command.push('--debug');
57+
}
58+
59+
command.push(utils.getSourceCodeGlob('js'));
60+
61+
processArguments.push(command);
62+
}
63+
}
64+
65+
if (toLint === 'md') {
66+
commandBinToRun = 'markdownlint';
67+
4268
const command = [
4369
'--config',
44-
utils.getRootFile('.eslintrc'),
45-
'--ignore-path',
46-
utils.getRootFile('.eslintignore'),
70+
utils.getRootFile('.markdownlint.json'),
4771
];
4872

49-
if (debug) {
50-
command.push('--debug');
51-
}
52-
53-
command.push(utils.getSourceCodeGlob('js'));
73+
command.push(utils.getRootGlob('md'));
5474

5575
processArguments.push(command);
5676
}
5777

58-
if (watch && toLint === 'js') {
59-
commandBinToRun = 'chokidar';
60-
processArguments.push([utils.getSourceCodeGlob('js'), '--initial', '-c npm run lint:js']);
61-
}
62-
6378
if (!processArguments.length) {
6479
console.error(colors.red('Error processing input. Please check your arguments and try again.'));
6580

packages/atlauncher-scripts/utils.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ function getRootFile(filename) {
9797
return defaultRootFile;
9898
}
9999

100+
function getRootGlob(type = 'js') {
101+
let sourceCodePath = getProjectBasePath();
102+
103+
if (sourceCodePath.substr(-1) === '/') {
104+
sourceCodePath = sourceCodePath.substr(0, sourceCodePath.length - 1);
105+
}
106+
107+
if (type === 'css') {
108+
return `${sourceCodePath}/*.{css,less,scss}`;
109+
}
110+
111+
return `${sourceCodePath}/*.${type}`;
112+
}
113+
100114
function getSourceCodeGlob(type = 'js') {
101115
let sourceCodePath = getSourceCodePath();
102116

0 commit comments

Comments
 (0)