Skip to content

Drop support for node <v12.22.0, v13, >=v14<v14.17.0, v15 and eslint v5 #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
865 changes: 855 additions & 10 deletions .eslintrc.yml

Large diffs are not rendered by default.

15 changes: 3 additions & 12 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,13 @@ jobs:
- eslint: 7
node: 12
os: ubuntu-latest
- eslint: 7
node: 10
os: ubuntu-latest
# On old ESLint versions
- eslint: 6
node: 14
os: ubuntu-latest
- eslint: 5
node: 14
os: ubuntu-latest
# On the minimum supported ESLint/Node.js version
- eslint: 5
node: 8.10.0
- eslint: 6
node: 12
os: ubuntu-latest

runs-on: ${{ matrix.os }}
Expand All @@ -69,11 +63,8 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install @typescript-eslint/parser@3
run: npm install -D @typescript-eslint/parser@3
if: matrix.node == '8.10.0'
- name: Install Packages
run: npm install
run: npm install --legacy-peer-deps
- name: Install ESLint v${{ matrix.eslint }}
run: node scripts/ci-install-eslint ${{ matrix.eslint }}
- name: Build
Expand Down
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ This parser allows us to lint the `<template>` of `.vue` files. We can make mist
## 💿 Installation

```bash
$ npm install --save-dev eslint vue-eslint-parser
npm install --save-dev eslint vue-eslint-parser
```

- Requires Node.js 6.5.0 or later.
- Requires ESLint 5.0.0 or later.
- Requires `babel-eslint` 8.1.1 or later if you want it. (optional)
- Requires `@typescript-eslint/parser` 1.0.0 or later if you want it. (optional)
- Requires Node.js ^12.22.0, ^14.17.0, 16.0.0 or later.
- Requires ESLint 6.0.0 or later.

## 📖 Usage

Expand Down Expand Up @@ -71,9 +69,8 @@ For example:
{
"parser": "vue-eslint-parser",
"parserOptions": {
"parser": "babel-eslint",
"sourceType": "module",
"allowImportExportEverywhere": false
"parser": "@babel/eslint-parser",
"sourceType": "module"
}
}
```
Expand All @@ -82,7 +79,8 @@ For example:
{
"parser": "vue-eslint-parser",
"parserOptions": {
"parser": "@typescript-eslint/parser"
"parser": "@typescript-eslint/parser",
"sourceType": "module"
}
}
```
Expand Down
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,49 @@
"version": "7.11.0",
"description": "The ESLint custom parser for `.vue` files.",
"engines": {
"node": ">=8.10"
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"main": "index.js",
"files": [
"index.*"
],
"peerDependencies": {
"eslint": ">=5.0.0"
"eslint": ">=6.0.0"
},
"dependencies": {
"debug": "^4.1.1",
"eslint-scope": "^5.1.1",
"eslint-visitor-keys": "^1.1.0",
"espree": "^6.2.1",
"debug": "^4.3.2",
"eslint-scope": "^6.0.0",
"eslint-visitor-keys": "^3.0.0",
"espree": "^9.0.0",
"esquery": "^1.4.0",
"lodash": "^4.17.21",
"semver": "^6.3.0"
"semver": "^7.3.5"
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/eslint-parser": "^7.15.0",
"@babel/plugin-syntax-decorators": "^7.14.5",
"@babel/plugin-syntax-pipeline-operator": "^7.15.0",
"@babel/plugin-syntax-typescript": "^7.14.5",
"@mysticatea/eslint-plugin": "^13.0.0",
"@types/debug": "0.0.30",
"@types/eslint": "^7.2.6",
"@types/estree": "0.0.45",
"@types/lodash": "^4.14.120",
"@types/mocha": "^5.2.4",
"@types/node": "^10.12.21",
"@types/semver": "^7.3.6",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.14.0",
"babel-eslint": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^5.0.0-0",
"@typescript-eslint/parser": "^5.0.0-0",
"chokidar": "^2.0.4",
"codecov": "^3.1.0",
"cross-spawn": "^6.0.5",
"dts-bundle": "^0.7.3",
"eslint": "^7.0.0",
"eslint": "^8.0.0-0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-jsonc": "^1.4.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-node-dependencies": "^0.5.0",
"eslint-plugin-prettier": "^4.0.0",
"fs-extra": "^7.0.1",
"jsonc-eslint-parser": "^0.6.0",
"mocha": "^6.1.4",
Expand Down
2 changes: 1 addition & 1 deletion src/ast/traverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See LICENSE file in root directory for full license.
*/
import type { VisitorKeys } from "eslint-visitor-keys"
import Evk from "eslint-visitor-keys"
import * as Evk from "eslint-visitor-keys"
import type { Node } from "./nodes"

//------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/common/create-require.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const createRequire: (filename: string) => (modname: string) => any =
// Added in v12.2.0
(Module as any).createRequire ||
// Added in v10.12.0, but deprecated in v12.2.0.
// eslint-disable-next-line @mysticatea/node/no-deprecated-api
// eslint-disable-next-line node/no-deprecated-api
Module.createRequireFromPath ||
// Polyfill - This is not executed on the tests on node@>=10.
/* istanbul ignore next */
Expand Down
2 changes: 1 addition & 1 deletion src/common/eslint-scope.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import escope from "eslint-scope"
import * as escope from "eslint-scope"
import { getLinterRequire } from "./linter-require"
import { lte } from "semver"

Expand Down
2 changes: 0 additions & 2 deletions src/html/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ export class Parser {
/**
* The current flag of expression enabled.
*/
// eslint-disable-next-line @mysticatea/ts/ban-ts-ignore
// @ts-ignore
private get expressionEnabled(): boolean {
return this.tokenizer.expressionEnabled
}
Expand Down
10 changes: 2 additions & 8 deletions src/parser-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ export function define(
generator,
)
} finally {
// eslint-disable-next-line @mysticatea/ts/ban-ts-ignore
// @ts-ignore
// @ts-expect-error -- ignore
scriptVisitor[templateBodyTriggerSelector] =
programExitHandler
templateBodyEmitters.delete(templateBodyTriggerSelector)
Expand Down Expand Up @@ -232,8 +231,6 @@ export function define(
})
traverseNodes(document, generator)
} finally {
// eslint-disable-next-line @mysticatea/ts/ban-ts-ignore
// @ts-ignore
scriptVisitor[documentTriggerSelector] =
programExitHandler
documentEmitters.delete(documentTriggerSelector)
Expand Down Expand Up @@ -337,8 +334,7 @@ export function define(
const ctx = {
...customBlockContext,
}
// eslint-disable-next-line @mysticatea/ts/ban-ts-ignore
// @ts-ignore -- custom context
// @ts-expect-error -- custom context
ctx.__proto__ = factory.context

const visitor = factory.create(
Expand Down Expand Up @@ -370,8 +366,6 @@ export function define(
})
}
} finally {
// eslint-disable-next-line @mysticatea/ts/ban-ts-ignore
// @ts-ignore
scriptVisitor["Program:exit"] = programExitHandler
customBlocksEmitters.delete(key)
}
Expand Down
2 changes: 1 addition & 1 deletion src/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ export interface ExpressionParseResult<T extends Node> {

function loadParser(parser: string) {
if (parser !== "espree") {
// eslint-disable-next-line @mysticatea/ts/no-require-imports
// eslint-disable-next-line @typescript-eslint/no-require-imports
return require(parser)
}
return getEspreeFromUser()
Expand Down
9 changes: 6 additions & 3 deletions src/sfc/custom-block/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export function parseCustomBlockElement(
parserOptions,
)
} catch (e) {
if (!(e instanceof Error)) {
throw e
}
return {
error: e,
ast: {
Expand Down Expand Up @@ -221,7 +224,7 @@ export function createCustomBlockSharedContext({
getAncestors: () => getAncestors(currentNode),

getDeclaredVariables: (...args: any[]) =>
// @ts-expect-error
// @ts-expect-error -- ignore
getScopeManager().getDeclaredVariables(...args),
getScope: () => getScope(getScopeManager(), currentNode),
markVariableAsUsed: (name: string) =>
Expand Down Expand Up @@ -256,7 +259,7 @@ export function createCustomBlockSharedContext({
function getSourceCode() {
return (
sourceCode ||
// eslint-disable-next-line @mysticatea/ts/no-require-imports
// eslint-disable-next-line @typescript-eslint/no-require-imports
(sourceCode = new (require("eslint").SourceCode)({
text,
ast: parsedResult.ast,
Expand Down Expand Up @@ -365,7 +368,7 @@ function markVariableAsUsed(
)

if (variable) {
// @ts-expect-error
// @ts-expect-error -- ignore
variable.eslintUsed = true
return true
}
Expand Down
36 changes: 18 additions & 18 deletions test/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ function getTree(source, parserOptions) {
type: node.type,
text: source.slice(node.range[0], node.range[1]),
children: [],
})
}),
)
},
"*:exit"() {
current = stack.pop()
},
})
}),
)
linter.verify(
source,
Expand All @@ -104,7 +104,7 @@ function getTree(source, parserOptions) {
rules: { maketree: "error" },
},
undefined,
true
true,
)

return root.children
Expand Down Expand Up @@ -140,19 +140,19 @@ function validateParent(source, parserOptions) {
node.parent === parent,
`The parent of ${nodeToString(
node,
source
source,
)} should be ${nodeToString(
parent,
source
)}, but got ${nodeToString(node.parent, source)}`
source,
)}, but got ${nodeToString(node.parent, source)}`,
)
}
stack.push(node)
},
"*:exit"() {
stack.pop()
},
})
}),
)
linter.verify(
source,
Expand All @@ -162,7 +162,7 @@ function validateParent(source, parserOptions) {
rules: { validateparent: "error" },
},
undefined,
true
true,
)
}

Expand All @@ -189,7 +189,7 @@ describe("Template AST", () => {
const options = Object.assign(
{ filePath: sourcePath },
PARSER_OPTIONS,
parserOptions
parserOptions,
)

if (
Expand All @@ -213,15 +213,15 @@ describe("Template AST", () => {

assert.strictEqual(
JSON.stringify(actual.ast, replacer, 4),
expected
expected,
)
})

it("should have correct range.", () => {
const resultPath = path.join(ROOT, `${name}/token-ranges.json`)
const expectedText = fs.readFileSync(resultPath, "utf8")
const tokens = getAllTokens(actual.ast).map((t) =>
source.slice(t.range[0], t.range[1])
source.slice(t.range[0], t.range[1]),
)
const actualText = JSON.stringify(tokens, null, 4)

Expand All @@ -232,15 +232,15 @@ describe("Template AST", () => {
const sourceForWin = source.replace(/\r?\n/gu, "\r\n")
const actualForWin = parser.parseForESLint(
sourceForWin,
options
options,
)

const resultPath = path.join(ROOT, `${name}/token-ranges.json`)
const expectedText = fs.readFileSync(resultPath, "utf8")
const tokens = getAllTokens(actualForWin.ast).map((t) =>
sourceForWin
.slice(t.range[0], t.range[1])
.replace(/\r?\n/gu, "\n")
.replace(/\r?\n/gu, "\n"),
)
const actualText = JSON.stringify(tokens, null, 4)

Expand All @@ -257,7 +257,7 @@ describe("Template AST", () => {
const column1 = token.loc.end.column
const expected = source.slice(
token.range[0],
token.range[1]
token.range[1],
)

let text = ""
Expand All @@ -277,10 +277,10 @@ describe("Template AST", () => {
`${JSON.stringify(
token,
null,
4
4,
)} expected ${JSON.stringify(
expected
)}, but got ${JSON.stringify(text)}`
expected,
)}, but got ${JSON.stringify(text)}`,
)
}
})
Expand All @@ -302,7 +302,7 @@ describe("Template AST", () => {
it("should have correct services.", () => {
assert.deepStrictEqual(
Object.keys(actual.services).sort(),
services
services,
)
})
}
Expand Down
2 changes: 1 addition & 1 deletion test/core-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function modifyPattern(ruleId, pattern) {
error.data &&
Object.hasOwnProperty.call(
error.data,
"shadowedLine"
"shadowedLine",
) &&
typeof error.data.shadowedLine === "number"
) {
Expand Down
Loading