|
| 1 | +import { dirname } from 'path' |
| 2 | +import { fileURLToPath } from 'url' |
| 3 | +import { FlatCompat } from '@eslint/eslintrc' |
| 4 | +import { defineConfig } from 'eslint/config' |
| 5 | + |
| 6 | +const __filename = fileURLToPath(import.meta.url) |
| 7 | +const __dirname = dirname(__filename) |
| 8 | + |
| 9 | +const compat = new FlatCompat({ |
| 10 | + baseDirectory: __dirname, |
| 11 | +}) |
| 12 | + |
| 13 | +export default defineConfig([ |
| 14 | + // coreWebVitals includes Next recommended rules |
| 15 | + ...compat.extends('plugin:@next/next/core-web-vitals'), |
| 16 | + { |
| 17 | + files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'], |
| 18 | + rules: { |
| 19 | + '@next/next/no-img-element': 'off', |
| 20 | + }, |
| 21 | + }, |
| 22 | +]) |
| 23 | + |
| 24 | +// Alternative/modern approach: |
| 25 | +// Working, but has some issues with the Next lint command (running with `next build`). |
| 26 | +// This approach can probably be used with Next 16, as they removed Next lint completely. |
| 27 | +// |
| 28 | +// import next from '@next/eslint-plugin-next' |
| 29 | +// import { defineConfig } from 'eslint/config' |
| 30 | +// export default defineConfig([ |
| 31 | +// { |
| 32 | +// files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'], |
| 33 | +// // coreWebVitals includes Next recommended rules |
| 34 | +// ...next.flatConfig.coreWebVitals, |
| 35 | +// rules: { |
| 36 | +// '@next/next/no-img-element': 'off', |
| 37 | +// }, |
| 38 | +// }, |
| 39 | +// ]) |
0 commit comments