chore(eslint): Configure and adjust
ESLint rules for the project
This commit is contained in:
parent
20f7d79474
commit
63e5a2ca9d
@ -5,31 +5,84 @@ import eslint from "@eslint/js";
|
||||
import nextPlugin from "@next/eslint-plugin-next";
|
||||
import unicornPlugin from "eslint-plugin-unicorn";
|
||||
import prettierConfig from "eslint-config-prettier";
|
||||
import { FlatCompat } from "@eslint/eslintrc";
|
||||
import { fileURLToPath } from "url";
|
||||
import { dirname } from "path";
|
||||
|
||||
export default [
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const compat = new FlatCompat({
|
||||
baseDirectory: __dirname
|
||||
});
|
||||
|
||||
const eslintConfig = [
|
||||
{
|
||||
ignores: ["node_modules/**", ".next/**", "out/**", "build/**", "next-env.d.ts"],
|
||||
},
|
||||
// Base JS/TS config
|
||||
{
|
||||
files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"],
|
||||
plugins: {
|
||||
"@next/next": nextPlugin,
|
||||
"unicorn": unicornPlugin,
|
||||
},
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
},
|
||||
parser: tseslint.parser,
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
"@next/next": nextPlugin,
|
||||
},
|
||||
rules: {
|
||||
...nextPlugin.configs.recommended.rules,
|
||||
...nextPlugin.configs["core-web-vitals"].rules,
|
||||
...unicornPlugin.configs.recommended.rules,
|
||||
...nextPlugin.configs.recommended.rules,
|
||||
...nextPlugin.configs["core-web-vitals"].rules,
|
||||
}
|
||||
},
|
||||
// TypeScript specific config
|
||||
{
|
||||
files: ["**/*.{ts,tsx}"],
|
||||
plugins: {
|
||||
"unicorn": unicornPlugin,
|
||||
},
|
||||
languageOptions: {
|
||||
parser: tseslint.parser,
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
...tseslint.configs.recommended.rules,
|
||||
...unicornPlugin.configs.recommended.rules,
|
||||
// Disable noisy unicorn rules
|
||||
"unicorn/prevent-abbreviations": "off",
|
||||
"unicorn/filename-case": "off",
|
||||
"unicorn/no-null": "off",
|
||||
"unicorn/consistent-function-scoping": "off",
|
||||
"unicorn/no-array-for-each": "off",
|
||||
"unicorn/catch-error-name": "off",
|
||||
"unicorn/explicit-length-check": "off",
|
||||
"unicorn/no-array-reduce": "off",
|
||||
"unicorn/prefer-spread": "off",
|
||||
"unicorn/no-document-cookie": "off",
|
||||
"unicorn/prefer-query-selector": "off",
|
||||
"unicorn/prefer-add-event-listener": "off",
|
||||
"unicorn/prefer-string-slice": "off",
|
||||
"unicorn/prefer-string-replace-all": "off",
|
||||
"unicorn/prefer-number-properties": "off",
|
||||
"unicorn/consistent-existence-index-check": "off",
|
||||
"unicorn/no-negated-condition": "off",
|
||||
"unicorn/switch-case-braces": "off",
|
||||
"unicorn/prefer-global-this": "off",
|
||||
"unicorn/no-useless-undefined": "off",
|
||||
"unicorn/no-array-callback-reference": "off",
|
||||
"unicorn/no-array-sort": "off",
|
||||
"unicorn/numeric-separators-style": "off",
|
||||
"unicorn/prefer-optional-catch-binding": "off",
|
||||
"unicorn/prefer-ternary": "off",
|
||||
"unicorn/prefer-code-point": "off",
|
||||
"unicorn/prefer-single-call": "off",
|
||||
}
|
||||
},
|
||||
prettierConfig,
|
||||
];
|
||||
...compat.extends("next/core-web-vitals"),
|
||||
];
|
||||
|
||||
export default eslintConfig;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
"scripts": {
|
||||
"build": "next build",
|
||||
"dev": "next dev",
|
||||
"lint": "next lint",
|
||||
"lint": "eslint .",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -86,6 +86,7 @@
|
||||
"tailwindcss": "^4.1.9",
|
||||
"tw-animate-css": "1.3.3",
|
||||
"typescript": "^5",
|
||||
"typescript-eslint": "^8.45.0"
|
||||
"typescript-eslint": "^8.45.0",
|
||||
"@eslint/eslintrc": "^3"
|
||||
}
|
||||
}
|
||||
|
||||
3
susconecta/pnpm-lock.yaml
generated
3
susconecta/pnpm-lock.yaml
generated
@ -183,6 +183,9 @@ importers:
|
||||
specifier: 3.25.67
|
||||
version: 3.25.67
|
||||
devDependencies:
|
||||
'@eslint/eslintrc':
|
||||
specifier: ^3
|
||||
version: 3.3.1
|
||||
'@eslint/js':
|
||||
specifier: ^9.36.0
|
||||
version: 9.36.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user