@w5s/eslint-config 1.0.0-alpha.36 → 1.0.0-alpha.38
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/ignore.js +1 -1
- package/package.json +6 -5
- package/rules/prettier.js +36 -7
package/ignore.js
CHANGED
|
@@ -7,7 +7,7 @@ const parseGitignore = require('parse-gitignore');
|
|
|
7
7
|
const getGitignore = () => {
|
|
8
8
|
const found = findUp.sync('.gitignore');
|
|
9
9
|
if (found) {
|
|
10
|
-
return parseGitignore(fs.readFileSync(found));
|
|
10
|
+
return parseGitignore.parse(fs.readFileSync(found)).patterns;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
return [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/eslint-config",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.38",
|
|
4
4
|
"description": "ESLint configuration presets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"@rushstack/eslint-patch": "^1.1.0",
|
|
52
52
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
53
53
|
"@typescript-eslint/parser": "^5.0.0",
|
|
54
|
+
"@w5s/prettier-config": "^1.0.1",
|
|
54
55
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
55
56
|
"eslint-config-prettier": "^8.0.0",
|
|
56
57
|
"eslint-plugin-functional": "^4.2.0",
|
|
@@ -65,7 +66,7 @@
|
|
|
65
66
|
"eslint-plugin-unicorn": "^44.0.0",
|
|
66
67
|
"eslint-plugin-yml": "^1.1.0",
|
|
67
68
|
"find-up": "^5.0.0",
|
|
68
|
-
"parse-gitignore": "^
|
|
69
|
+
"parse-gitignore": "^2.0.0"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
72
|
"@babel/eslint-parser": "7.19.1",
|
|
@@ -73,8 +74,8 @@
|
|
|
73
74
|
"@types/eslint-plugin-prettier": "3.1.0",
|
|
74
75
|
"@types/prettier": "2.7.1",
|
|
75
76
|
"@types/react": "18.0.25",
|
|
76
|
-
"@typescript-eslint/parser": "5.
|
|
77
|
-
"eslint": "8.
|
|
77
|
+
"@typescript-eslint/parser": "5.43.0",
|
|
78
|
+
"eslint": "8.28.0",
|
|
78
79
|
"eslint-config-prettier": "8.5.0",
|
|
79
80
|
"eslint-index": "1.5.0",
|
|
80
81
|
"prettier": "2.7.1",
|
|
@@ -96,5 +97,5 @@
|
|
|
96
97
|
"publishConfig": {
|
|
97
98
|
"access": "public"
|
|
98
99
|
},
|
|
99
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "a00eaebeac309aaab9b5ebbe53b19b66e8faca94"
|
|
100
101
|
}
|
package/rules/prettier.js
CHANGED
|
@@ -1,15 +1,44 @@
|
|
|
1
1
|
const { error } = require('./_rule.js');
|
|
2
2
|
|
|
3
|
+
const getPackageScope = () => {
|
|
4
|
+
try {
|
|
5
|
+
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
6
|
+
const { name } = require('../package.json');
|
|
7
|
+
const prefixMatch = (name || '').match(/(@\w+)\//);
|
|
8
|
+
const packageScope = prefixMatch ? prefixMatch[1] : undefined;
|
|
9
|
+
return packageScope;
|
|
10
|
+
} catch (error_) {
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
12
|
+
console.warn(error_);
|
|
13
|
+
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const getPrettierConfig = (/** @type {string} */ moduleName) => {
|
|
18
|
+
try {
|
|
19
|
+
/** @type {import('prettier').Config} */
|
|
20
|
+
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
21
|
+
const moduleConfig = require(moduleName);
|
|
22
|
+
return moduleConfig;
|
|
23
|
+
} catch {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Try require '@my-organization/prettier-config'
|
|
29
|
+
const getPrettierConfigDefault = () => {
|
|
30
|
+
/** @type {import('prettier').Config} */
|
|
31
|
+
const defaultConfig = {
|
|
32
|
+
trailingComma: 'es5',
|
|
33
|
+
};
|
|
34
|
+
const packageScope = getPackageScope();
|
|
35
|
+
return getPrettierConfig(`${packageScope}/prettier-config`) || defaultConfig;
|
|
36
|
+
};
|
|
37
|
+
|
|
3
38
|
module.exports = {
|
|
4
39
|
extends: ['prettier'],
|
|
5
40
|
plugins: ['prettier'],
|
|
6
41
|
rules: {
|
|
7
|
-
'prettier/prettier': [
|
|
8
|
-
error,
|
|
9
|
-
{
|
|
10
|
-
singleQuote: true,
|
|
11
|
-
trailingComma: 'es5',
|
|
12
|
-
},
|
|
13
|
-
],
|
|
42
|
+
'prettier/prettier': [error, getPrettierConfigDefault()],
|
|
14
43
|
},
|
|
15
44
|
};
|