Skip to content

Commit 88e354d

Browse files
committed
chore: remove compat for eslint v6
1 parent 917787c commit 88e354d

File tree

2 files changed

+7
-73
lines changed

2 files changed

+7
-73
lines changed

tests/eslint-compat.js

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let FlatESLint = eslint.ESLint
88
let Linter = eslint.Linter
99
let RuleTester = eslint.RuleTester
1010
if (semver.lt(eslint.Linter.version, '9.0.0-0')) {
11-
ESLint = eslint.ESLint ? getESLintClassForV8() : getESLintClassForV6()
11+
ESLint = getESLintClassForV8()
1212
Linter = getLinterClassForV8()
1313
RuleTester = getRuleTesterClassForV8()
1414
try {
@@ -68,71 +68,6 @@ function getESLintClassForV8(BaseESLintClass = eslint.ESLint) {
6868
return newOptions
6969
}
7070
}
71-
/** @returns {typeof eslint.ESLint} */
72-
function getESLintClassForV6() {
73-
class ESLintForV6 {
74-
static get version() {
75-
// @ts-expect-error
76-
return eslint.CLIEngine.version
77-
}
78-
79-
/** @param {eslint.ESLint.Options} options */
80-
constructor(options) {
81-
const {
82-
overrideConfig: { plugins, globals, rules, ...overrideConfig } = {
83-
plugins: [],
84-
globals: {},
85-
rules: {}
86-
},
87-
fix,
88-
reportUnusedDisableDirectives,
89-
plugins: pluginsMap,
90-
...otherOptions
91-
} = options || {}
92-
93-
const newOptions = {
94-
fix: Boolean(fix),
95-
reportUnusedDisableDirectives: reportUnusedDisableDirectives
96-
? reportUnusedDisableDirectives !== 'off'
97-
: undefined,
98-
...otherOptions,
99-
100-
globals: globals
101-
? Object.keys(globals).filter((n) => globals[n])
102-
: undefined,
103-
plugins: plugins || [],
104-
rules: rules
105-
? Object.fromEntries(
106-
Object.entries(rules).flatMap(([ruleId, opt]) =>
107-
opt ? [[ruleId, opt]] : []
108-
)
109-
)
110-
: undefined,
111-
...overrideConfig
112-
}
113-
114-
// @ts-expect-error
115-
this.engine = new eslint.CLIEngine(newOptions)
116-
117-
for (const [name, plugin] of Object.entries(pluginsMap || {})) {
118-
this.engine.addPlugin(name, plugin)
119-
}
120-
}
121-
122-
/**
123-
* @param {Parameters<eslint.ESLint['lintText']>} params
124-
* @returns {ReturnType<eslint.ESLint['lintText']>}
125-
*/
126-
async lintText(...params) {
127-
const result = this.engine.executeOnText(params[0], params[1]?.filePath)
128-
return result.results
129-
}
130-
}
131-
132-
/** @type {typeof eslint.ESLint} */
133-
const eslintClass = /** @type {any} */ (ESLintForV6)
134-
return getESLintClassForV8(eslintClass)
135-
}
13671

13772
/** @returns {typeof eslint.Linter} */
13873
function getLinterClassForV8() {

tests/lib/rules/no-extra-parens.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ tester.run('no-extra-parens', rule, {
9494
<button
9595
:class="{
9696
a: (b || c),
97-
// [(d + e)]: f // valid in eslint v6.0
97+
[(d + e)]: f
9898
}"
9999
/>
100100
</template>`,
@@ -103,7 +103,7 @@ tester.run('no-extra-parens', rule, {
103103
<button
104104
:class="{
105105
a: b || c,
106-
// [(d + e)]: f // valid in eslint v6.0
106+
[d + e]: f
107107
}"
108108
/>
109109
</template>`,
@@ -114,12 +114,11 @@ tester.run('no-extra-parens', rule, {
114114
column: 16,
115115
endLine: 5,
116116
endColumn: 17
117+
},
118+
{
119+
messageId: 'unexpected',
120+
line: 6
117121
}
118-
// valid in eslint v6.0
119-
// {
120-
// messageId: 'unexpected',
121-
// line: 6
122-
// }
123122
]
124123
},
125124
{

0 commit comments

Comments
 (0)