upgrade to eslint v10 (#34054)
* upgrade from eslint version 8 to eslint version 10 * remove unsupported eslint-env directive * include jsx files in latexqc linting * use basePath and extends to maintain paths in writefull eslint * fix yarn.lock with ./bin/yarn install * preserve existing glob patterns in web eslint config * restore original comments * fix worker path * corrected comment about eslint-plugin-mocha * remove unused imports * remove unused import of includeIgnoreFile * switch to individual eslit.config.mjs files * fix lint errors on eslint.config.mjs in web * update build scripts for eslint.config.mjs * update volumes for RUN_LINTING_CI_MONOREPO in web Makefile updated manually as this makefile is not autogenerated the RUN_LINTING_CI_MONOREPO command is only used for prettier, not eslint, but updating for consistency. * migrate from mocha/no-skipped-tests to mocha/no-pending-tests see https://github.com/lo1tuma/eslint-plugin-mocha/pull/365 "rule no-skipped-tests has been removed, its functionality has been merged into the existing no-pending-tests rule" GitOrigin-RevId: 2c8f25c8049a0dba374a51df1214286bb5093a51
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
const pkg = require('./package.json')
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
name: pkg.name,
|
||||
version: pkg.version,
|
||||
},
|
||||
rules: {
|
||||
'no-unnecessary-trans': require('./no-unnecessary-trans'),
|
||||
'prefer-kebab-url': require('./prefer-kebab-url'),
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
"lodash": "^4.18.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/parser": "^8.50.0"
|
||||
"@typescript-eslint/parser": "^8.59.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.51.0"
|
||||
"eslint": "^10.4.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node rules.test.js"
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
const currentFilePath = context.getFilename()
|
||||
const currentFilePath = context.filename
|
||||
// ESLint can sometimes pass <text> or <input> for snippets not in a file
|
||||
if (currentFilePath === '<text>' || currentFilePath === '<input>') {
|
||||
return {}
|
||||
@@ -81,9 +81,10 @@ module.exports = {
|
||||
typeof firstArg.value !== 'string'
|
||||
) {
|
||||
if (firstArg.type === 'Identifier') {
|
||||
const variable = context
|
||||
.getScope()
|
||||
.variables.find(v => v.name === firstArg.name)
|
||||
const scope = context.sourceCode.getScope(node)
|
||||
const variable = scope.variables.find(
|
||||
v => v.name === firstArg.name
|
||||
)
|
||||
if (
|
||||
variable &&
|
||||
variable.defs.length > 0 &&
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { RuleTester } = require('eslint')
|
||||
const tsParser = require('@typescript-eslint/parser')
|
||||
const noThrowInCallback = require('./no-throw-in-callback')
|
||||
const preferKebabUrl = require('./prefer-kebab-url')
|
||||
const noUnnecessaryTrans = require('./no-unnecessary-trans')
|
||||
@@ -8,10 +9,10 @@ const viDoMockValidPath = require('./require-vi-doMock-valid-path')
|
||||
const requireCioSnakeCaseProperties = require('./require-cio-snake-case-properties')
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parser: require.resolve('@typescript-eslint/parser'),
|
||||
parserOptions: {
|
||||
languageOptions: {
|
||||
parser: tsParser,
|
||||
ecmaVersion: 'latest',
|
||||
ecmaFeatures: { jsx: true },
|
||||
parserOptions: { ecmaFeatures: { jsx: true } },
|
||||
},
|
||||
})
|
||||
|
||||
@@ -33,19 +34,27 @@ ruleTester.run('prefer-kebab-url', preferKebabUrl, {
|
||||
invalid: [
|
||||
{
|
||||
code: `app.get('/fooBar')`,
|
||||
errors: [{ message: 'Route path should be in kebab-case.' }],
|
||||
errors: [
|
||||
{ message: 'Route path should be in kebab-case.', suggestions: 1 },
|
||||
],
|
||||
},
|
||||
{
|
||||
code: `app.get('/fooBar/:id')`,
|
||||
errors: [{ message: 'Route path should be in kebab-case.' }],
|
||||
errors: [
|
||||
{ message: 'Route path should be in kebab-case.', suggestions: 1 },
|
||||
],
|
||||
},
|
||||
{
|
||||
code: `webRouter.get('/foo_bar/:id/FooBar/:name/fooBar')`,
|
||||
errors: [{ message: 'Route path should be in kebab-case.' }],
|
||||
errors: [
|
||||
{ message: 'Route path should be in kebab-case.', suggestions: 1 },
|
||||
],
|
||||
},
|
||||
{
|
||||
code: `router.get(/^\\/downLoad\\/pro-ject\\/([^/]*)\\/OutPut\\/out-put\\.pdf$/)`,
|
||||
errors: [{ message: 'Route path should be in kebab-case.' }],
|
||||
errors: [
|
||||
{ message: 'Route path should be in kebab-case.', suggestions: 1 },
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
@@ -153,6 +162,7 @@ ruleTester.run('domock-require-valid-path', viDoMockValidPath, {
|
||||
{
|
||||
message:
|
||||
'The path "./require-vi-doMock-valid-path2" in vi.doMock() cannot be resolved relative to the current file.',
|
||||
suggestions: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -163,6 +173,7 @@ ruleTester.run('domock-require-valid-path', viDoMockValidPath, {
|
||||
{
|
||||
message:
|
||||
'The first argument of vi.doMock() must be (or resolve to) a string literal representing a path.',
|
||||
suggestions: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user