Skip to content

Commit 4deaca7

Browse files
authored
chore: add prettier & lint-staged (#7)
* chore: add prettier & lint-staged the package was using eslint to enforce a code style(@mysticatea/eslint-config) while it's no longer maintained. It just added a prettier config to be close to the eslint config * fix: ignore .eslintcache * chore: do not run prettier on md files for less changes * chore: fix linting errors refs: prettier/prettier#12137 * chore: prettier lib/* tests/lib/* * chore: add eol
1 parent df759eb commit 4deaca7

File tree

74 files changed

+356
-511
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+356
-511
lines changed

.eslintrc.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@
88
// to make the ci passing.
99
module.exports = {
1010
reportUnusedDisableDirectives: true,
11-
extends: ["eslint:recommended", "plugin:n/recommended", "plugin:eslint-plugin/recommended"],
11+
extends: [
12+
"eslint:recommended",
13+
"plugin:n/recommended",
14+
"plugin:eslint-plugin/recommended",
15+
"prettier",
16+
],
1217
env: {
1318
mocha: true,
14-
}
15-
};
19+
},
20+
}
1621

1722
// const version = require("./package.json").version
1823

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/npm-debug.log
44
/node_modules
55
/test.js
6+
.eslintcache

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

.prettierrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"useTabs": false,
3+
"semi": false,
4+
"tabWidth": 4,
5+
"arrowParens": "avoid",
6+
"overrides": [
7+
{
8+
"files": "*.md",
9+
"options": {
10+
"printWidth": 70,
11+
"trailingComma": "none",
12+
"proseWrap": "never"
13+
}
14+
}
15+
]
16+
}

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = {
4646
"prefer-promises/dns": require("./rules/prefer-promises/dns"),
4747
"prefer-promises/fs": require("./rules/prefer-promises/fs"),
4848
"process-exit-as-throw": require("./rules/process-exit-as-throw"),
49-
"shebang": require("./rules/shebang"),
49+
shebang: require("./rules/shebang"),
5050

5151
// Deprecated rules.
5252
"no-hide-core-modules": require("./rules/no-hide-core-modules"),

lib/rules/callback-return.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ module.exports = {
1111
description: "require `return` statements after callbacks",
1212
category: "Stylistic Issues",
1313
recommended: false,
14-
url:
15-
"https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/callback-return.md",
14+
url: "https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/callback-return.md",
1615
},
1716
schema: [
1817
{

lib/rules/exports-style.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ module.exports = {
145145
description: "enforce either `module.exports` or `exports`",
146146
category: "Stylistic Issues",
147147
recommended: false,
148-
url:
149-
"https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/exports-style.md",
148+
url: "https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/exports-style.md",
150149
},
151150
type: "suggestion",
152151
fixable: null,

lib/rules/file-extension-in-import.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const fs = require("fs")
99
const getTryExtensions = require("../util/get-try-extensions")
1010
const visitImport = require("../util/visit-import")
1111
const packageNamePattern = /^(?:@[^/\\]+[/\\])?[^/\\]+$/u
12-
const corePackageOverridePattern = /^(?:assert|async_hooks|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|http2|https|inspector|module|net|os|path|perf_hooks|process|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|trace_events|tty|url|util|v8|vm|worker_threads|zlib)[/\\]$/u
12+
const corePackageOverridePattern =
13+
/^(?:assert|async_hooks|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|http2|https|inspector|module|net|os|path|perf_hooks|process|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|trace_events|tty|url|util|v8|vm|worker_threads|zlib)[/\\]$/u
1314

1415
/**
1516
* Get all file extensions of the files which have the same basename.
@@ -38,8 +39,7 @@ module.exports = {
3839
"enforce the style of file extensions in `import` declarations",
3940
category: "Stylistic Issues",
4041
recommended: false,
41-
url:
42-
"https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/file-extension-in-import.md",
42+
url: "https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/file-extension-in-import.md",
4343
},
4444
fixable: "code",
4545
messages: {

lib/rules/global-require.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ module.exports = {
5555
"require `require()` calls to be placed at top-level module scope",
5656
category: "Stylistic Issues",
5757
recommended: false,
58-
url:
59-
"https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/global-require.md",
58+
url: "https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/global-require.md",
6059
},
6160
fixable: null,
6261
schema: [],

0 commit comments

Comments
 (0)