eslint-config-prettier 8.9.0 → 9.0.0
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/bin/cli.js +34 -5
- package/index.js +1 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -8,9 +8,19 @@ const prettier = require("../prettier");
|
|
|
8
8
|
|
|
9
9
|
// Require locally installed eslint, for `npx eslint-config-prettier` support
|
|
10
10
|
// with no local eslint-config-prettier installation.
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const localRequire = (request) =>
|
|
12
|
+
require(require.resolve(request, {
|
|
13
|
+
paths: [process.cwd(), ...require.resolve.paths("eslint")],
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
let experimentalApi = {};
|
|
17
|
+
try {
|
|
18
|
+
experimentalApi = localRequire("eslint/use-at-your-own-risk");
|
|
19
|
+
// eslint-disable-next-line unicorn/prefer-optional-catch-binding
|
|
20
|
+
} catch (_error) {}
|
|
21
|
+
|
|
22
|
+
const { ESLint, FlatESLint = experimentalApi.FlatESLint } =
|
|
23
|
+
localRequire("eslint");
|
|
14
24
|
|
|
15
25
|
const SPECIAL_RULES_URL =
|
|
16
26
|
"https://github.com/prettier/eslint-config-prettier#special-rules";
|
|
@@ -27,8 +37,27 @@ if (module === require.main) {
|
|
|
27
37
|
}
|
|
28
38
|
|
|
29
39
|
const eslint = new ESLint();
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
const flatESLint = FlatESLint === undefined ? undefined : new FlatESLint();
|
|
41
|
+
|
|
42
|
+
Promise.all(
|
|
43
|
+
args.map((file) => {
|
|
44
|
+
switch (process.env.ESLINT_USE_FLAT_CONFIG) {
|
|
45
|
+
case "true": {
|
|
46
|
+
return flatESLint.calculateConfigForFile(file);
|
|
47
|
+
}
|
|
48
|
+
case "false": {
|
|
49
|
+
return eslint.calculateConfigForFile(file);
|
|
50
|
+
}
|
|
51
|
+
default: {
|
|
52
|
+
// This turns synchronous errors (such as `.calculateConfigForFile` not existing)
|
|
53
|
+
// and turns them into promise rejections.
|
|
54
|
+
return Promise.resolve()
|
|
55
|
+
.then(() => flatESLint.calculateConfigForFile(file))
|
|
56
|
+
.catch(() => eslint.calculateConfigForFile(file));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
)
|
|
32
61
|
.then((configs) => {
|
|
33
62
|
const rules = configs.flatMap(({ rules }, index) =>
|
|
34
63
|
Object.entries(rules).map((entry) => [...entry, args[index]])
|
package/index.js
CHANGED
|
@@ -45,6 +45,7 @@ module.exports = {
|
|
|
45
45
|
"key-spacing": "off",
|
|
46
46
|
"keyword-spacing": "off",
|
|
47
47
|
"linebreak-style": "off",
|
|
48
|
+
"max-statements-per-line": "off",
|
|
48
49
|
"multiline-ternary": "off",
|
|
49
50
|
"newline-per-chained-call": "off",
|
|
50
51
|
"new-parens": "off",
|
|
@@ -76,7 +77,6 @@ module.exports = {
|
|
|
76
77
|
"switch-colon-spacing": "off",
|
|
77
78
|
"template-curly-spacing": "off",
|
|
78
79
|
"template-tag-spacing": "off",
|
|
79
|
-
"unicode-bom": "off",
|
|
80
80
|
"wrap-iife": "off",
|
|
81
81
|
"wrap-regex": "off",
|
|
82
82
|
"yield-star-spacing": "off",
|