generated from idea2app/Next-Bootstrap-ts
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheslint.config.mjs
76 lines (71 loc) · 2.32 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// @ts-check
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import eslint from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import reactPlugin from 'eslint-plugin-react';
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
import globals from 'globals';
import tsEslint from 'typescript-eslint';
import { fileURLToPath } from 'url';
const tsconfigRootDir = fileURLToPath(new URL('.', import.meta.url)),
flatCompat = new FlatCompat();
export default tsEslint.config(
// register all of the plugins up-front
{
plugins: {
'@typescript-eslint': tsEslint.plugin,
react: fixupPluginRules(reactPlugin),
'simple-import-sort': simpleImportSortPlugin,
},
},
{
// config with just ignores is the replacement for `.eslintignore`
ignores: ['**/node_modules/**', '**/public/**', '**/.next/**'],
},
// extends ...
eslint.configs.recommended,
...tsEslint.configs.recommended,
...fixupConfigRules(flatCompat.extends('plugin:@next/next/core-web-vitals')),
// base config
{
languageOptions: {
globals: { ...globals.es2020, ...globals.browser, ...globals.node },
parserOptions: {
projectService: true,
tsconfigRootDir,
warnOnUnsupportedTypeScriptVersion: false,
},
},
rules: {
'no-empty-pattern': 'warn',
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unsafe-declaration-merging': 'warn',
'react/jsx-no-target-blank': 'warn',
'react/jsx-sort-props': [
'error',
{
reservedFirst: true,
callbacksLast: true,
noSortAlphabetically: true,
},
],
'@next/next/no-sync-scripts': 'warn',
},
},
{
files: ['**/*.js'],
extends: [tsEslint.configs.disableTypeChecked],
rules: {
// turn off other type-aware rules
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
// turn off rules that don't apply to JS code
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
eslintConfigPrettier,
);