mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
ESLint plugin defaults to flat config, and we also dropped the built-in lint check at https://github.com/vercel/next.js/pull/83136, so we can sunset the deprecated ESLint v8 testing.
49 lines
937 B
TypeScript
49 lines
937 B
TypeScript
import { RuleTester } from 'eslint'
|
|
import { rules } from '@next/eslint-plugin-next'
|
|
|
|
const NextESLintRule = rules['no-assign-module-variable']
|
|
|
|
const tests = {
|
|
valid: [
|
|
`
|
|
let myModule = {};
|
|
|
|
export default function MyComponent() {
|
|
return <></>
|
|
}
|
|
`,
|
|
],
|
|
invalid: [
|
|
{
|
|
code: `
|
|
let module = {};
|
|
|
|
export default function MyComponent() {
|
|
return <></>
|
|
}
|
|
`,
|
|
errors: [
|
|
{
|
|
message:
|
|
'Do not assign to the variable `module`. See: https://nextjs.org/docs/messages/no-assign-module-variable',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}
|
|
|
|
describe('no-assign-module-variable', () => {
|
|
new RuleTester({
|
|
languageOptions: {
|
|
ecmaVersion: 2018,
|
|
sourceType: 'module',
|
|
parserOptions: {
|
|
ecmaFeatures: {
|
|
modules: true,
|
|
jsx: true,
|
|
},
|
|
},
|
|
},
|
|
}).run('eslint', NextESLintRule, tests)
|
|
})
|