Skip to content

Commit 2326231

Browse files
BPScottnot-an-aardvark
authored andcommitted
Breaking: Drop support for ESLint v3 and v4
ESLint v5.0.0 is the minimum supported version
1 parent 1ec94c8 commit 2326231

File tree

4 files changed

+36
-95
lines changed

4 files changed

+36
-95
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ node_js:
77
env:
88
- ESLINT_VERSION=current
99
- ESLINT_VERSION=^5
10-
- ESLINT_VERSION=^4
11-
- ESLINT_VERSION=^3
1210
install:
1311
- if [[ $ESLINT_VERSION != "current" ]]; then
1412
yarn upgrade "eslint@$ESLINT_VERSION";

eslint-plugin-prettier.js

+7-45
Original file line numberDiff line numberDiff line change
@@ -41,46 +41,6 @@ let prettier;
4141
// Helpers
4242
// ------------------------------------------------------------------------------
4343

44-
/**
45-
* Gets the location of a given index in the source code for a given context.
46-
* @param {RuleContext} context - The ESLint rule context.
47-
* @param {number} index - An index in the source code.
48-
* @returns {Object} An object containing numeric `line` and `column` keys.
49-
*/
50-
function getLocFromIndex(context, index) {
51-
// If `sourceCode.getLocFromIndex` is available from ESLint, use it - added
52-
// in ESLint 3.16.0.
53-
const sourceCode = context.getSourceCode();
54-
if (typeof sourceCode.getLocFromIndex === 'function') {
55-
return sourceCode.getLocFromIndex(index);
56-
}
57-
const text = sourceCode.getText();
58-
if (typeof index !== 'number') {
59-
throw new TypeError('Expected `index` to be a number.');
60-
}
61-
if (index < 0 || index > text.length) {
62-
throw new RangeError('Index out of range.');
63-
}
64-
// Loosely based on
65-
// https://github.com/eslint/eslint/blob/18a519fa/lib/ast-utils.js#L408-L438
66-
const lineEndingPattern = /\r\n|[\r\n\u2028\u2029]/g;
67-
let offset = 0;
68-
let line = 0;
69-
let match;
70-
while ((match = lineEndingPattern.exec(text))) {
71-
const next = match.index + match[0].length;
72-
if (index < next) {
73-
break;
74-
}
75-
line++;
76-
offset = next;
77-
}
78-
return {
79-
line: line + 1,
80-
column: index - offset
81-
};
82-
}
83-
8444
/**
8545
* Converts invisible characters to a commonly recognizable visible form.
8646
* @param {string} str - The string with invisibles to convert.
@@ -225,7 +185,7 @@ function generateDifferences(source, prettierSource) {
225185
* @returns {void}
226186
*/
227187
function reportInsert(context, offset, text) {
228-
const pos = getLocFromIndex(context, offset);
188+
const pos = context.getSourceCode().getLocFromIndex(offset);
229189
const range = [offset, offset];
230190
context.report({
231191
message: 'Insert `{{ code }}`',
@@ -245,8 +205,8 @@ function reportInsert(context, offset, text) {
245205
* @returns {void}
246206
*/
247207
function reportDelete(context, offset, text) {
248-
const start = getLocFromIndex(context, offset);
249-
const end = getLocFromIndex(context, offset + text.length);
208+
const start = context.getSourceCode().getLocFromIndex(offset);
209+
const end = context.getSourceCode().getLocFromIndex(offset + text.length);
250210
const range = [offset, offset + text.length];
251211
context.report({
252212
message: 'Delete `{{ code }}`',
@@ -268,8 +228,10 @@ function reportDelete(context, offset, text) {
268228
* @returns {void}
269229
*/
270230
function reportReplace(context, offset, deleteText, insertText) {
271-
const start = getLocFromIndex(context, offset);
272-
const end = getLocFromIndex(context, offset + deleteText.length);
231+
const start = context.getSourceCode().getLocFromIndex(offset);
232+
const end = context
233+
.getSourceCode()
234+
.getLocFromIndex(offset + deleteText.length);
273235
const range = [offset, offset + deleteText.length];
274236
context.report({
275237
message: 'Replace `{{ deleteCode }}` with `{{ insertCode }}`',

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
"eslint-config-not-an-aardvark": "^2.1.0",
4040
"eslint-config-prettier": "^3.1.0",
4141
"eslint-plugin-eslint-plugin": "^1.4.0",
42-
"eslint-plugin-node": "^6.0.1",
42+
"eslint-plugin-node": "^7.0.1",
4343
"eslint-plugin-self": "^1.1.0",
4444
"mocha": "^5.2.0",
4545
"prettier": "^1.13.0",
46-
"vue-eslint-parser": "^2.0.3"
46+
"vue-eslint-parser": "^3.2.2"
4747
},
4848
"engines": {
4949
"node": ">=6.0.0"

yarn.lock

+27-46
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,13 @@
2323
moment "^2.18.1"
2424
semver "^5.4.1"
2525

26-
acorn-jsx@^3.0.0:
27-
version "3.0.1"
28-
resolved "http://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b"
29-
dependencies:
30-
acorn "^3.0.4"
31-
3226
acorn-jsx@^4.1.1:
3327
version "4.1.1"
3428
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-4.1.1.tgz#e8e41e48ea2fe0c896740610ab6a4ffd8add225e"
3529
dependencies:
3630
acorn "^5.0.3"
3731

38-
acorn@^3.0.4:
39-
version "3.3.0"
40-
resolved "http://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"
41-
42-
acorn@^5.0.3, acorn@^5.5.0, acorn@^5.6.0:
32+
acorn@^5.0.3, acorn@^5.6.0:
4333
version "5.7.3"
4434
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279"
4535

@@ -221,38 +211,40 @@ eslint-config-prettier@^3.1.0:
221211
dependencies:
222212
get-stdin "^6.0.0"
223213

214+
eslint-plugin-es@^1.3.1:
215+
version "1.3.1"
216+
resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-1.3.1.tgz#5acb2565db4434803d1d46a9b4cbc94b345bd028"
217+
dependencies:
218+
eslint-utils "^1.3.0"
219+
regexpp "^2.0.0"
220+
224221
eslint-plugin-eslint-plugin@^1.4.0:
225222
version "1.4.0"
226223
resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-plugin/-/eslint-plugin-eslint-plugin-1.4.0.tgz#382dc6692a741a52072d5f3fff5dacdcf291ef49"
227224

228-
eslint-plugin-node@^6.0.1:
229-
version "6.0.1"
230-
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-6.0.1.tgz#bf19642298064379315d7a4b2a75937376fa05e4"
225+
eslint-plugin-node@^7.0.1:
226+
version "7.0.1"
227+
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-7.0.1.tgz#a6e054e50199b2edd85518b89b4e7b323c9f36db"
231228
dependencies:
232-
ignore "^3.3.6"
229+
eslint-plugin-es "^1.3.1"
230+
eslint-utils "^1.3.1"
231+
ignore "^4.0.2"
233232
minimatch "^3.0.4"
234-
resolve "^1.3.3"
235-
semver "^5.4.1"
233+
resolve "^1.8.1"
234+
semver "^5.5.0"
236235

237236
eslint-plugin-self@^1.1.0:
238237
version "1.1.0"
239238
resolved "https://registry.yarnpkg.com/eslint-plugin-self/-/eslint-plugin-self-1.1.0.tgz#e95b26d599f17ca0ef63dbaace8bff13c599eaef"
240239

241-
eslint-scope@^3.7.1:
242-
version "3.7.3"
243-
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.3.tgz#bb507200d3d17f60247636160b4826284b108535"
244-
dependencies:
245-
esrecurse "^4.1.0"
246-
estraverse "^4.1.1"
247-
248240
eslint-scope@^4.0.0:
249241
version "4.0.0"
250242
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.0.tgz#50bf3071e9338bcdc43331794a0cb533f0136172"
251243
dependencies:
252244
esrecurse "^4.1.0"
253245
estraverse "^4.1.1"
254246

255-
eslint-utils@^1.3.1:
247+
eslint-utils@^1.3.0, eslint-utils@^1.3.1:
256248
version "1.3.1"
257249
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.3.1.tgz#9a851ba89ee7c460346f97cf8939c7298827e512"
258250

@@ -303,13 +295,6 @@ eslint@^5.6.0:
303295
table "^4.0.3"
304296
text-table "^0.2.0"
305297

306-
espree@^3.5.2:
307-
version "3.5.4"
308-
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7"
309-
dependencies:
310-
acorn "^5.5.0"
311-
acorn-jsx "^3.0.0"
312-
313298
espree@^4.0.0:
314299
version "4.0.0"
315300
resolved "https://registry.yarnpkg.com/espree/-/espree-4.0.0.tgz#253998f20a0f82db5d866385799d912a83a36634"
@@ -321,7 +306,7 @@ esprima@^4.0.0:
321306
version "4.0.1"
322307
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
323308

324-
esquery@^1.0.0, esquery@^1.0.1:
309+
esquery@^1.0.1:
325310
version "1.0.1"
326311
resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708"
327312
dependencies:
@@ -458,11 +443,7 @@ iconv-lite@^0.4.24:
458443
dependencies:
459444
safer-buffer ">= 2.1.2 < 3"
460445

461-
ignore@^3.3.6:
462-
version "3.3.10"
463-
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043"
464-
465-
ignore@^4.0.6:
446+
ignore@^4.0.2, ignore@^4.0.6:
466447
version "4.0.6"
467448
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
468449

@@ -717,7 +698,7 @@ resolve-from@^1.0.0:
717698
version "1.0.1"
718699
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"
719700

720-
resolve@^1.3.3:
701+
resolve@^1.8.1:
721702
version "1.8.1"
722703
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26"
723704
dependencies:
@@ -850,16 +831,16 @@ uri-js@^4.2.2:
850831
dependencies:
851832
punycode "^2.1.0"
852833

853-
vue-eslint-parser@^2.0.3:
854-
version "2.0.3"
855-
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-2.0.3.tgz#c268c96c6d94cfe3d938a5f7593959b0ca3360d1"
834+
vue-eslint-parser@^3.2.2:
835+
version "3.2.2"
836+
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-3.2.2.tgz#47c971ee4c39b0ee7d7f5e154cb621beb22f7a34"
856837
dependencies:
857838
debug "^3.1.0"
858-
eslint-scope "^3.7.1"
839+
eslint-scope "^4.0.0"
859840
eslint-visitor-keys "^1.0.0"
860-
espree "^3.5.2"
861-
esquery "^1.0.0"
862-
lodash "^4.17.4"
841+
espree "^4.0.0"
842+
esquery "^1.0.1"
843+
lodash "^4.17.10"
863844

864845
which@^1.2.9:
865846
version "1.3.1"

0 commit comments

Comments
 (0)