Skip to content

Commit 27b44d6

Browse files
committed
Chore: upgrade ESLint that tests are using
1 parent f704031 commit 27b44d6

7 files changed

+17
-93
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"warun": "^1.0.0"
5151
},
5252
"scripts": {
53-
"_mocha": "_mocha \"test/*.js\" --reporter dot --timeout 5000",
53+
"_mocha": "_mocha \"test/*.js\" --reporter dot --timeout 10000",
5454
"prebuild": "npm run -s clean",
5555
"build": "tsc && rollup -c -o index.js && dts-bundle --name vue-eslint-parser --main .temp/index.d.ts --out ../index.d.ts",
5656
"clean": "rimraf .nyc_output .temp coverage index.*",

test/ast.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const fs = require("fs")
1414
const path = require("path")
1515
const lodash = require("lodash")
1616
const parser = require("..")
17-
const linter = require("./fixtures/eslint").linter
17+
const Linter = require("./fixtures/eslint").Linter
1818

1919
//------------------------------------------------------------------------------
2020
// Helpers
@@ -71,11 +71,11 @@ function getAllTokens(ast) {
7171
* @returns {object} Simple tree.
7272
*/
7373
function getTree(source) {
74+
const linter = new Linter()
7475
const stack = []
7576
const root = {children: []}
7677
let current = root
7778

78-
linter.reset()
7979
linter.defineRule("maketree", (ruleContext) =>
8080
ruleContext.parserServices.defineTemplateBodyVisitor({
8181
"*"(node) {
@@ -111,9 +111,9 @@ function getTree(source) {
111111
* @returns {void}
112112
*/
113113
function validateParent(source) {
114+
const linter = new Linter()
114115
const stack = []
115116

116-
linter.reset()
117117
linter.defineRule("validateparent", (ruleContext) =>
118118
ruleContext.parserServices.defineTemplateBodyVisitor({
119119
"*"(node) {

test/core-rules.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const RuleTester = require("./fixtures/eslint/lib/testers/rule-tester")
1717
// Helpers
1818
//------------------------------------------------------------------------------
1919

20-
const RULES_ROOT = path.join(__dirname, "fixtures/eslint/tests/lib/rules")
20+
const RULE_DEFS_ROOT = path.join(__dirname, "fixtures/eslint/lib/rules")
21+
const RULE_TESTS_ROOT = path.join(__dirname, "fixtures/eslint/tests/lib/rules")
2122
const PARSER_PATH = path.resolve(__dirname, "../index.js")
2223
const EXCEPTIONS = new Set([
2324
// Those rules check outside `<script>` tag as well.
@@ -34,9 +35,8 @@ const EXCEPTIONS = new Set([
3435
// are added.
3536
// It cannot test this rule correctly.
3637
"lines-around-comment",
37-
"lines-around-directive",
38-
"newline-after-var",
3938
"no-multiple-empty-lines",
39+
"semi-style",
4040

4141
// The inside of "<script>" tags is not related to Unicode BOM.
4242
"unicode-bom",
@@ -131,14 +131,18 @@ function overrideRun(ruleId, impl, patterns) {
131131
RuleTester.prototype.run = overrideRun
132132
try {
133133
describe("Tests of ESLint core rules", () => {
134-
for (const fileName of fs.readdirSync(RULES_ROOT)) {
135-
if (path.extname(fileName) !== ".js" ||
136-
EXCEPTIONS.has(path.basename(fileName, ".js"))
137-
) {
134+
for (const fileName of fs.readdirSync(RULE_TESTS_ROOT)) {
135+
if (path.extname(fileName) !== ".js" || fileName.startsWith("_")) {
136+
continue
137+
}
138+
if (require(path.join(RULE_DEFS_ROOT, fileName)).meta.deprecated) {
139+
continue
140+
}
141+
if (EXCEPTIONS.has(path.basename(fileName, ".js"))) {
138142
continue
139143
}
140144

141-
require(path.join(RULES_ROOT, fileName))
145+
require(path.join(RULE_TESTS_ROOT, fileName))
142146
}
143147
})
144148
}

test/fixtures/eslint

Submodule eslint updated 643 files

test/fixtures/lines-around-directive-always.vue.fixed

-15
This file was deleted.

test/fixtures/lines-around-directive.vue

-14
This file was deleted.

test/index.js

-51
Original file line numberDiff line numberDiff line change
@@ -186,57 +186,6 @@ describe("Basic tests", () => {
186186
})
187187
})
188188

189-
describe("About fixtures/lines-around-directive.vue", () => {
190-
it("should notify no 'lines-around-directive' error (never)", () => {
191-
const cli = new CLIEngine({
192-
cwd: FIXTURE_DIR,
193-
envs: ["es6", "node"],
194-
parser: PARSER_PATH,
195-
rules: {"lines-around-directive": ["error", "never"]},
196-
useEslintrc: false,
197-
})
198-
const report = cli.executeOnFiles(["lines-around-directive.vue"])
199-
const messages = report.results[0].messages
200-
201-
assert(messages.length === 0)
202-
})
203-
204-
it("should notify a 'lines-around-directive' error (always)", () => {
205-
const cli = new CLIEngine({
206-
cwd: FIXTURE_DIR,
207-
envs: ["es6", "node"],
208-
parser: PARSER_PATH,
209-
rules: {"lines-around-directive": ["error", "always"]},
210-
useEslintrc: false,
211-
})
212-
const report = cli.executeOnFiles(["lines-around-directive.vue"])
213-
const messages = report.results[0].messages
214-
215-
assert(messages.length === 1)
216-
assert(messages[0].ruleId === "lines-around-directive")
217-
assert(messages[0].line === 6)
218-
assert(messages[0].column === 1)
219-
assert(messages[0].source === "\"use strict\"")
220-
})
221-
222-
it("should fix 'lines-around-directive' errors with --fix option", () => {
223-
const cli = new CLIEngine({
224-
cwd: FIXTURE_DIR,
225-
envs: ["es6", "node"],
226-
fix: true,
227-
parser: PARSER_PATH,
228-
rules: {"lines-around-directive": ["error", "always"]},
229-
useEslintrc: false,
230-
})
231-
CLIEngine.outputFixes(cli.executeOnFiles(["lines-around-directive.vue"]))
232-
233-
const actual = fs.readFileSync(path.join(FIXTURE_DIR, "lines-around-directive.vue"), "utf8")
234-
const expected = fs.readFileSync(path.join(FIXTURE_DIR, "lines-around-directive-always.vue.fixed"), "utf8")
235-
236-
assert(actual === expected)
237-
})
238-
})
239-
240189
describe("About fixtures/crlf.vue", () => {
241190
it("should notify no 'indent' error", () => {
242191
const cli = new CLIEngine({

0 commit comments

Comments
 (0)