Skip to content

Commit c46d791

Browse files
committed
Add eslint and editorconfig configurations
1 parent 00e6c4f commit c46d791

File tree

5 files changed

+36
-42
lines changed

5 files changed

+36
-42
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
"extends": "standard"
3+
};

index.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const fs = require('fs-extra');
2-
const path = require('path');
1+
const fs = require('fs-extra')
2+
const path = require('path')
33

4-
function getTemplate(path) {
4+
function getTemplate (path) {
55
const result = '<!DOCTYPE html>' +
66
'<html>' +
77
'<head>' +
@@ -10,28 +10,28 @@ function getTemplate(path) {
1010
'<link rel="canonical" href="' + path + '">' +
1111
'<meta http-equiv="refresh" content="0; url=' + path + '">' +
1212
'</head>' +
13-
'</html>';
13+
'</html>'
1414

15-
return result;
15+
return result
1616
}
1717

1818
module.exports = (options, ctx) => ({
1919
async generated (pagePaths) {
20-
const { pages, outDir } = ctx;
20+
const { pages, outDir } = ctx
2121

22-
pages.filter(({frontmatter}) => {
23-
return frontmatter.alias || frontmatter.aliases;
22+
pages.filter(({ frontmatter }) => {
23+
return frontmatter.alias || frontmatter.aliases
2424
}).forEach(page => {
25-
let aliases = page.frontmatter.alias || page.frontmatter.aliases;
26-
if (!Array.isArray(aliases)) aliases = [aliases];
27-
if (!aliases.length) return;
25+
let aliases = page.frontmatter.alias || page.frontmatter.aliases
26+
if (!Array.isArray(aliases)) aliases = [aliases]
27+
if (!aliases.length) return
2828

29-
const content = getTemplate(page.path);
29+
const content = getTemplate(page.path)
3030

3131
aliases.forEach(async alias => {
32-
const aliasPagePath = path.resolve(outDir, alias);
33-
await fs.outputFile(aliasPagePath, content);
34-
});
32+
const aliasPagePath = path.resolve(outDir, alias)
33+
await fs.outputFile(aliasPagePath, content)
34+
})
3535
})
3636
}
3737
})

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@
2424
},
2525
"homepage": "https://github.com/vaniyokk/vuepress-plugin-alias#readme",
2626
"dependencies": {
27-
"fs-extra": "^7.0.1",
28-
"path": "^0.12.7"
27+
"fs-extra": "^7.0.1"
28+
},
29+
"devDependencies": {
30+
"eslint": "^5.10.0",
31+
"eslint-config-standard": "^12.0.0",
32+
"eslint-plugin-import": "^2.14.0",
33+
"eslint-plugin-node": "^8.0.0",
34+
"eslint-plugin-promise": "^4.0.1",
35+
"eslint-plugin-standard": "^4.0.0"
2936
}
3037
}

yarn.lock

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,14 @@ graceful-fs@^4.1.2, graceful-fs@^4.1.6:
1616
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"
1717
integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==
1818

19-
20-
version "2.0.3"
21-
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
22-
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
23-
2419
jsonfile@^4.0.0:
2520
version "4.0.0"
2621
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
2722
integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
2823
optionalDependencies:
2924
graceful-fs "^4.1.6"
3025

31-
path@^0.12.7:
32-
version "0.12.7"
33-
resolved "https://registry.yarnpkg.com/path/-/path-0.12.7.tgz#d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f"
34-
integrity sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=
35-
dependencies:
36-
process "^0.11.1"
37-
util "^0.10.3"
38-
39-
process@^0.11.1:
40-
version "0.11.10"
41-
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
42-
integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI=
43-
4426
universalify@^0.1.0:
4527
version "0.1.2"
4628
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
4729
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
48-
49-
util@^0.10.3:
50-
version "0.10.4"
51-
resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901"
52-
integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==
53-
dependencies:
54-
inherits "2.0.3"

0 commit comments

Comments
 (0)