eslint-plugin-prettier 3.4.1 → 4.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/CHANGELOG.md +8 -0
- package/eslint-plugin-prettier.js +22 -55
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v4.0.0 (2021-08-30)
|
|
4
|
+
|
|
5
|
+
This breaking change drops support for old versions of ESLint, Prettier and
|
|
6
|
+
Node. You must use at least ESLint v7.28.0, Prettier v2.0.0 and Node v12.0.0.
|
|
7
|
+
Aside from that, usage of this plugin remains identical.
|
|
8
|
+
|
|
9
|
+
* v4 - Drop support for eslint 5/6, prettier 1, node 6/8 ([#429](git@github.com:prettier/eslint-plugin-prettier/issues/429)) ([acb56f3](git@github.com:prettier/eslint-plugin-prettier/commit/acb56f3b2891b2a6998a75a7d4406183d452ba16))
|
|
10
|
+
|
|
3
11
|
## v3.4.1 (2021-08-20)
|
|
4
12
|
|
|
5
13
|
* build(deps): Bump glob-parent from 5.0.0 to 5.1.2 ([#420](git@github.com:prettier/eslint-plugin-prettier/issues/420)) ([b6d075c](git@github.com:prettier/eslint-plugin-prettier/commit/b6d075cf7111468e8af4161c306c7f37f09f220e))
|
|
@@ -9,12 +9,9 @@
|
|
|
9
9
|
// Requirements
|
|
10
10
|
// ------------------------------------------------------------------------------
|
|
11
11
|
|
|
12
|
-
const fs = require('fs');
|
|
13
|
-
const path = require('path');
|
|
14
|
-
|
|
15
12
|
const {
|
|
16
13
|
showInvisibles,
|
|
17
|
-
generateDifferences
|
|
14
|
+
generateDifferences,
|
|
18
15
|
} = require('prettier-linter-helpers');
|
|
19
16
|
|
|
20
17
|
// ------------------------------------------------------------------------------
|
|
@@ -46,7 +43,7 @@ let prettier;
|
|
|
46
43
|
function reportDifference(context, difference) {
|
|
47
44
|
const { operation, offset, deleteText = '', insertText = '' } = difference;
|
|
48
45
|
const range = [offset, offset + deleteText.length];
|
|
49
|
-
const [start, end] = range.map(index =>
|
|
46
|
+
const [start, end] = range.map((index) =>
|
|
50
47
|
context.getSourceCode().getLocFromIndex(index)
|
|
51
48
|
);
|
|
52
49
|
|
|
@@ -54,35 +51,13 @@ function reportDifference(context, difference) {
|
|
|
54
51
|
messageId: operation,
|
|
55
52
|
data: {
|
|
56
53
|
deleteText: showInvisibles(deleteText),
|
|
57
|
-
insertText: showInvisibles(insertText)
|
|
54
|
+
insertText: showInvisibles(insertText),
|
|
58
55
|
},
|
|
59
56
|
loc: { start, end },
|
|
60
|
-
fix: fixer => fixer.replaceTextRange(range, insertText)
|
|
57
|
+
fix: (fixer) => fixer.replaceTextRange(range, insertText),
|
|
61
58
|
});
|
|
62
59
|
}
|
|
63
60
|
|
|
64
|
-
/**
|
|
65
|
-
* Given a filepath, get the nearest path that is a regular file.
|
|
66
|
-
* The filepath provided by eslint may be a virtual filepath rather than a file
|
|
67
|
-
* on disk. This attempts to transform a virtual path into an on-disk path
|
|
68
|
-
* @param {string} filepath
|
|
69
|
-
* @returns {string}
|
|
70
|
-
*/
|
|
71
|
-
function getOnDiskFilepath(filepath) {
|
|
72
|
-
try {
|
|
73
|
-
if (fs.statSync(filepath).isFile()) {
|
|
74
|
-
return filepath;
|
|
75
|
-
}
|
|
76
|
-
} catch (err) {
|
|
77
|
-
// https://github.com/eslint/eslint/issues/11989
|
|
78
|
-
if (err.code === 'ENOTDIR') {
|
|
79
|
-
return getOnDiskFilepath(path.dirname(filepath));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return filepath;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
61
|
// ------------------------------------------------------------------------------
|
|
87
62
|
// Module Definition
|
|
88
63
|
// ------------------------------------------------------------------------------
|
|
@@ -95,15 +70,15 @@ module.exports = {
|
|
|
95
70
|
rules: {
|
|
96
71
|
'prettier/prettier': 'error',
|
|
97
72
|
'arrow-body-style': 'off',
|
|
98
|
-
'prefer-arrow-callback': 'off'
|
|
99
|
-
}
|
|
100
|
-
}
|
|
73
|
+
'prefer-arrow-callback': 'off',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
101
76
|
},
|
|
102
77
|
rules: {
|
|
103
78
|
prettier: {
|
|
104
79
|
meta: {
|
|
105
80
|
docs: {
|
|
106
|
-
url: 'https://github.com/prettier/eslint-plugin-prettier#options'
|
|
81
|
+
url: 'https://github.com/prettier/eslint-plugin-prettier#options',
|
|
107
82
|
},
|
|
108
83
|
type: 'layout',
|
|
109
84
|
fixable: 'code',
|
|
@@ -112,7 +87,7 @@ module.exports = {
|
|
|
112
87
|
{
|
|
113
88
|
type: 'object',
|
|
114
89
|
properties: {},
|
|
115
|
-
additionalProperties: true
|
|
90
|
+
additionalProperties: true,
|
|
116
91
|
},
|
|
117
92
|
{
|
|
118
93
|
type: 'object',
|
|
@@ -121,17 +96,17 @@ module.exports = {
|
|
|
121
96
|
fileInfoOptions: {
|
|
122
97
|
type: 'object',
|
|
123
98
|
properties: {},
|
|
124
|
-
additionalProperties: true
|
|
125
|
-
}
|
|
99
|
+
additionalProperties: true,
|
|
100
|
+
},
|
|
126
101
|
},
|
|
127
|
-
additionalProperties: true
|
|
128
|
-
}
|
|
102
|
+
additionalProperties: true,
|
|
103
|
+
},
|
|
129
104
|
],
|
|
130
105
|
messages: {
|
|
131
106
|
[INSERT]: 'Insert `{{ insertText }}`',
|
|
132
107
|
[DELETE]: 'Delete `{{ deleteText }}`',
|
|
133
|
-
[REPLACE]: 'Replace `{{ deleteText }}` with `{{ insertText }}`'
|
|
134
|
-
}
|
|
108
|
+
[REPLACE]: 'Replace `{{ deleteText }}` with `{{ insertText }}`',
|
|
109
|
+
},
|
|
135
110
|
},
|
|
136
111
|
create(context) {
|
|
137
112
|
const usePrettierrc =
|
|
@@ -145,9 +120,7 @@ module.exports = {
|
|
|
145
120
|
// file paths. If this is the case then we need to resolve prettier
|
|
146
121
|
// config and file info using the on-disk path instead of the virtual
|
|
147
122
|
// path.
|
|
148
|
-
|
|
149
|
-
// being able to get this value directly from eslint in the future.
|
|
150
|
-
const onDiskFilepath = getOnDiskFilepath(filepath);
|
|
123
|
+
const onDiskFilepath = context.getPhysicalFilename();
|
|
151
124
|
const source = sourceCode.text;
|
|
152
125
|
|
|
153
126
|
return {
|
|
@@ -161,7 +134,7 @@ module.exports = {
|
|
|
161
134
|
|
|
162
135
|
const prettierRcOptions = usePrettierrc
|
|
163
136
|
? prettier.resolveConfig.sync(onDiskFilepath, {
|
|
164
|
-
editorconfig: true
|
|
137
|
+
editorconfig: true,
|
|
165
138
|
})
|
|
166
139
|
: null;
|
|
167
140
|
|
|
@@ -221,13 +194,7 @@ module.exports = {
|
|
|
221
194
|
}
|
|
222
195
|
|
|
223
196
|
if (filepath === onDiskFilepath && inferParserToBabel) {
|
|
224
|
-
|
|
225
|
-
// Use the modern name if available
|
|
226
|
-
const supportBabelParser = prettier
|
|
227
|
-
.getSupportInfo()
|
|
228
|
-
.languages.some(language => language.parsers.includes('babel'));
|
|
229
|
-
|
|
230
|
-
initialOptions.parser = supportBabelParser ? 'babel' : 'babylon';
|
|
197
|
+
initialOptions.parser = 'babel';
|
|
231
198
|
}
|
|
232
199
|
|
|
233
200
|
const prettierOptions = Object.assign(
|
|
@@ -279,9 +246,9 @@ module.exports = {
|
|
|
279
246
|
reportDifference(context, difference);
|
|
280
247
|
}
|
|
281
248
|
}
|
|
282
|
-
}
|
|
249
|
+
},
|
|
283
250
|
};
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
},
|
|
287
254
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-prettier",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Runs prettier as an eslint rule",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -31,19 +31,21 @@
|
|
|
31
31
|
"prettier-linter-helpers": "^1.0.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"eslint": ">=
|
|
35
|
-
"prettier": ">=
|
|
34
|
+
"eslint": ">=7.28.0",
|
|
35
|
+
"prettier": ">=2.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
+
"@graphql-eslint/eslint-plugin": "^2.0.1",
|
|
38
39
|
"@not-an-aardvark/node-release-script": "^0.1.0",
|
|
39
|
-
"eslint": "^7.
|
|
40
|
+
"eslint": "^7.28.0",
|
|
40
41
|
"eslint-config-not-an-aardvark": "^2.1.0",
|
|
41
42
|
"eslint-config-prettier": "^6.0.0",
|
|
42
43
|
"eslint-plugin-eslint-plugin": "^2.0.0",
|
|
43
44
|
"eslint-plugin-node": "^8.0.0",
|
|
44
45
|
"eslint-plugin-self": "^1.1.0",
|
|
46
|
+
"graphql": "^15.5.1",
|
|
45
47
|
"mocha": "^6.0.0",
|
|
46
|
-
"prettier": "^
|
|
48
|
+
"prettier": "^2.3.0",
|
|
47
49
|
"vue-eslint-parser": "^6.0.0"
|
|
48
50
|
},
|
|
49
51
|
"peerDependenciesMeta": {
|