eslint-config-prettier 8.10.0 → 9.1.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 CHANGED
@@ -8,9 +8,21 @@ 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 { ESLint } = require(require.resolve("eslint", {
12
- paths: [process.cwd(), ...require.resolve.paths("eslint")],
13
- }));
11
+ const localRequire = (request) =>
12
+ require(
13
+ require.resolve(request, {
14
+ paths: [process.cwd(), ...require.resolve.paths("eslint")],
15
+ })
16
+ );
17
+
18
+ let experimentalApi = {};
19
+ try {
20
+ experimentalApi = localRequire("eslint/use-at-your-own-risk");
21
+ // eslint-disable-next-line unicorn/prefer-optional-catch-binding
22
+ } catch (_error) {}
23
+
24
+ const { ESLint, FlatESLint = experimentalApi.FlatESLint } =
25
+ localRequire("eslint");
14
26
 
15
27
  const SPECIAL_RULES_URL =
16
28
  "https://github.com/prettier/eslint-config-prettier#special-rules";
@@ -27,8 +39,27 @@ if (module === require.main) {
27
39
  }
28
40
 
29
41
  const eslint = new ESLint();
30
-
31
- Promise.all(args.map((file) => eslint.calculateConfigForFile(file)))
42
+ const flatESLint = FlatESLint === undefined ? undefined : new FlatESLint();
43
+
44
+ Promise.all(
45
+ args.map((file) => {
46
+ switch (process.env.ESLINT_USE_FLAT_CONFIG) {
47
+ case "true": {
48
+ return flatESLint.calculateConfigForFile(file);
49
+ }
50
+ case "false": {
51
+ return eslint.calculateConfigForFile(file);
52
+ }
53
+ default: {
54
+ // This turns synchronous errors (such as `.calculateConfigForFile` not existing)
55
+ // and turns them into promise rejections.
56
+ return Promise.resolve()
57
+ .then(() => flatESLint.calculateConfigForFile(file))
58
+ .catch(() => eslint.calculateConfigForFile(file));
59
+ }
60
+ }
61
+ })
62
+ )
32
63
  .then((configs) => {
33
64
  const rules = configs.flatMap(({ rules }, index) =>
34
65
  Object.entries(rules).map((entry) => [...entry, args[index]])
package/bin/validators.js CHANGED
@@ -48,6 +48,29 @@ module.exports = {
48
48
  return Boolean(firstOption && firstOption.allowIndentationTabs);
49
49
  },
50
50
 
51
+ "unicorn/template-indent"({ options }) {
52
+ if (options.length === 0) {
53
+ return false;
54
+ }
55
+
56
+ const { comments = [], tags = [] } = options[0] || {};
57
+
58
+ return (
59
+ Array.isArray(comments) &&
60
+ Array.isArray(tags) &&
61
+ !(
62
+ comments.includes("GraphQL") ||
63
+ comments.includes("HTML") ||
64
+ tags.includes("css") ||
65
+ tags.includes("graphql") ||
66
+ tags.includes("gql") ||
67
+ tags.includes("html") ||
68
+ tags.includes("markdown") ||
69
+ tags.includes("md")
70
+ )
71
+ );
72
+ },
73
+
51
74
  "vue/html-self-closing"({ options }) {
52
75
  if (options.length === 0) {
53
76
  return false;
package/index.js CHANGED
@@ -2,85 +2,24 @@
2
2
 
3
3
  const includeDeprecated = !process.env.ESLINT_CONFIG_PRETTIER_NO_DEPRECATED;
4
4
 
5
+ const specialRule = 0;
6
+
5
7
  module.exports = {
6
8
  rules: {
7
9
  // The following rules can be used in some cases. See the README for more
8
- // information. (These are marked with `0` instead of `"off"` so that a
9
- // script can distinguish them.)
10
- "curly": 0,
11
- "lines-around-comment": 0,
12
- "max-len": 0,
13
- "no-confusing-arrow": 0,
14
- "no-mixed-operators": 0,
15
- "no-tabs": 0,
16
- "no-unexpected-multiline": 0,
17
- "quotes": 0,
18
- "@typescript-eslint/lines-around-comment": 0,
19
- "@typescript-eslint/quotes": 0,
20
- "babel/quotes": 0,
21
- "vue/html-self-closing": 0,
22
- "vue/max-len": 0,
10
+ // information. These are marked with `0` instead of `"off"` so that a
11
+ // script can distinguish them. Note that there are a few more of these
12
+ // in the deprecated section below.
13
+ "curly": specialRule,
14
+ "no-unexpected-multiline": specialRule,
15
+ "@typescript-eslint/lines-around-comment": specialRule,
16
+ "@typescript-eslint/quotes": specialRule,
17
+ "babel/quotes": specialRule,
18
+ "unicorn/template-indent": specialRule,
19
+ "vue/html-self-closing": specialRule,
20
+ "vue/max-len": specialRule,
23
21
 
24
22
  // The rest are rules that you never need to enable when using Prettier.
25
- "array-bracket-newline": "off",
26
- "array-bracket-spacing": "off",
27
- "array-element-newline": "off",
28
- "arrow-parens": "off",
29
- "arrow-spacing": "off",
30
- "block-spacing": "off",
31
- "brace-style": "off",
32
- "comma-dangle": "off",
33
- "comma-spacing": "off",
34
- "comma-style": "off",
35
- "computed-property-spacing": "off",
36
- "dot-location": "off",
37
- "eol-last": "off",
38
- "func-call-spacing": "off",
39
- "function-call-argument-newline": "off",
40
- "function-paren-newline": "off",
41
- "generator-star-spacing": "off",
42
- "implicit-arrow-linebreak": "off",
43
- "indent": "off",
44
- "jsx-quotes": "off",
45
- "key-spacing": "off",
46
- "keyword-spacing": "off",
47
- "linebreak-style": "off",
48
- "max-statements-per-line": "off",
49
- "multiline-ternary": "off",
50
- "newline-per-chained-call": "off",
51
- "new-parens": "off",
52
- "no-extra-parens": "off",
53
- "no-extra-semi": "off",
54
- "no-floating-decimal": "off",
55
- "no-mixed-spaces-and-tabs": "off",
56
- "no-multi-spaces": "off",
57
- "no-multiple-empty-lines": "off",
58
- "no-trailing-spaces": "off",
59
- "no-whitespace-before-property": "off",
60
- "nonblock-statement-body-position": "off",
61
- "object-curly-newline": "off",
62
- "object-curly-spacing": "off",
63
- "object-property-newline": "off",
64
- "one-var-declaration-per-line": "off",
65
- "operator-linebreak": "off",
66
- "padded-blocks": "off",
67
- "quote-props": "off",
68
- "rest-spread-spacing": "off",
69
- "semi": "off",
70
- "semi-spacing": "off",
71
- "semi-style": "off",
72
- "space-before-blocks": "off",
73
- "space-before-function-paren": "off",
74
- "space-in-parens": "off",
75
- "space-infix-ops": "off",
76
- "space-unary-ops": "off",
77
- "switch-colon-spacing": "off",
78
- "template-curly-spacing": "off",
79
- "template-tag-spacing": "off",
80
- "unicode-bom": "off",
81
- "wrap-iife": "off",
82
- "wrap-regex": "off",
83
- "yield-star-spacing": "off",
84
23
  "@babel/object-curly-spacing": "off",
85
24
  "@babel/semi": "off",
86
25
  "@typescript-eslint/block-spacing": "off",
@@ -173,51 +112,103 @@ module.exports = {
173
112
  "vue/template-curly-spacing": "off",
174
113
 
175
114
  ...(includeDeprecated && {
115
+ // Removed in version 0.10.0.
116
+ // https://eslint.org/docs/latest/rules/space-unary-word-ops
117
+ "space-unary-word-ops": "off",
118
+
176
119
  // Removed in version 1.0.0.
177
- // https://eslint.org/docs/latest/rules/generator-star
120
+ // https://github.com/eslint/eslint/issues/1898
178
121
  "generator-star": "off",
179
- // Deprecated since version 4.0.0.
180
- // https://github.com/eslint/eslint/pull/8286
181
- "indent-legacy": "off",
182
- // Removed in version 2.0.0.
183
- // https://eslint.org/docs/latest/rules/no-arrow-condition
184
- "no-arrow-condition": "off",
185
- // Removed in version 1.0.0.
186
- // https://eslint.org/docs/latest/rules/no-comma-dangle
187
122
  "no-comma-dangle": "off",
188
- // Removed in version 1.0.0.
189
- // https://eslint.org/docs/latest/rules/no-reserved-keys
190
123
  "no-reserved-keys": "off",
191
- // Removed in version 1.0.0.
192
- // https://eslint.org/docs/latest/rules/no-space-before-semi
193
124
  "no-space-before-semi": "off",
194
- // Deprecated since version 3.3.0.
195
- // https://eslint.org/docs/rules/no-spaced-func
196
- "no-spaced-func": "off",
197
- // Removed in version 1.0.0.
198
- // https://eslint.org/docs/latest/rules/no-wrap-func
199
125
  "no-wrap-func": "off",
200
- // Removed in version 1.0.0.
201
- // https://eslint.org/docs/latest/rules/space-after-function-name
202
126
  "space-after-function-name": "off",
203
- // Removed in version 2.0.0.
204
- // https://eslint.org/docs/latest/rules/space-after-keywords
205
- "space-after-keywords": "off",
206
- // Removed in version 1.0.0.
207
- // https://eslint.org/docs/latest/rules/space-before-function-parentheses
208
127
  "space-before-function-parentheses": "off",
209
- // Removed in version 2.0.0.
210
- // https://eslint.org/docs/latest/rules/space-before-keywords
211
- "space-before-keywords": "off",
212
- // Removed in version 1.0.0.
213
- // https://eslint.org/docs/latest/rules/space-in-brackets
214
128
  "space-in-brackets": "off",
129
+
215
130
  // Removed in version 2.0.0.
216
- // https://eslint.org/docs/latest/rules/space-return-throw-case
131
+ // https://github.com/eslint/eslint/issues/5032
132
+ "no-arrow-condition": "off",
133
+ "space-after-keywords": "off",
134
+ "space-before-keywords": "off",
217
135
  "space-return-throw-case": "off",
218
- // Removed in version 0.10.0.
219
- // https://eslint.org/docs/latest/rules/space-unary-word-ops
220
- "space-unary-word-ops": "off",
136
+
137
+ // Deprecated since version 3.3.0.
138
+ // https://eslint.org/docs/rules/no-spaced-func
139
+ "no-spaced-func": "off",
140
+
141
+ // Deprecated since version 4.0.0.
142
+ // https://github.com/eslint/eslint/pull/8286
143
+ "indent-legacy": "off",
144
+
145
+ // Deprecated since version 8.53.0.
146
+ // https://eslint.org/blog/2023/10/deprecating-formatting-rules/
147
+ "array-bracket-newline": "off",
148
+ "array-bracket-spacing": "off",
149
+ "array-element-newline": "off",
150
+ "arrow-parens": "off",
151
+ "arrow-spacing": "off",
152
+ "block-spacing": "off",
153
+ "brace-style": "off",
154
+ "comma-dangle": "off",
155
+ "comma-spacing": "off",
156
+ "comma-style": "off",
157
+ "computed-property-spacing": "off",
158
+ "dot-location": "off",
159
+ "eol-last": "off",
160
+ "func-call-spacing": "off",
161
+ "function-call-argument-newline": "off",
162
+ "function-paren-newline": "off",
163
+ "generator-star-spacing": "off",
164
+ "implicit-arrow-linebreak": "off",
165
+ "indent": "off",
166
+ "jsx-quotes": "off",
167
+ "key-spacing": "off",
168
+ "keyword-spacing": "off",
169
+ "linebreak-style": "off",
170
+ "lines-around-comment": specialRule,
171
+ "max-len": specialRule,
172
+ "max-statements-per-line": "off",
173
+ "multiline-ternary": "off",
174
+ "new-parens": "off",
175
+ "newline-per-chained-call": "off",
176
+ "no-confusing-arrow": specialRule,
177
+ "no-extra-parens": "off",
178
+ "no-extra-semi": "off",
179
+ "no-floating-decimal": "off",
180
+ "no-mixed-operators": specialRule,
181
+ "no-mixed-spaces-and-tabs": "off",
182
+ "no-multi-spaces": "off",
183
+ "no-multiple-empty-lines": "off",
184
+ "no-tabs": specialRule,
185
+ "no-trailing-spaces": "off",
186
+ "no-whitespace-before-property": "off",
187
+ "nonblock-statement-body-position": "off",
188
+ "object-curly-newline": "off",
189
+ "object-curly-spacing": "off",
190
+ "object-property-newline": "off",
191
+ "one-var-declaration-per-line": "off",
192
+ "operator-linebreak": "off",
193
+ "padded-blocks": "off",
194
+ "quote-props": "off",
195
+ "quotes": specialRule,
196
+ "rest-spread-spacing": "off",
197
+ "semi": "off",
198
+ "semi-spacing": "off",
199
+ "semi-style": "off",
200
+ "space-before-blocks": "off",
201
+ "space-before-function-paren": "off",
202
+ "space-in-parens": "off",
203
+ "space-infix-ops": "off",
204
+ "space-unary-ops": "off",
205
+ "switch-colon-spacing": "off",
206
+ "template-curly-spacing": "off",
207
+ "template-tag-spacing": "off",
208
+ "wrap-iife": "off",
209
+ "wrap-regex": "off",
210
+ "yield-star-spacing": "off",
211
+
221
212
  // Deprecated since version 7.0.0.
222
213
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md#700---2017-05-06
223
214
  "react/jsx-space-before-closing": "off",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-prettier",
3
- "version": "8.10.0",
3
+ "version": "9.1.0",
4
4
  "license": "MIT",
5
5
  "author": "Simon Lydell",
6
6
  "description": "Turns off all rules that are unnecessary or might conflict with Prettier.",