riseup-squad20/susconecta/eslint.config.js

94 lines
2.7 KiB
JavaScript

// eslint.config.js
import globals from "globals";
import tseslint from "typescript-eslint";
import eslint from "@eslint/js";
import nextPlugin from "@next/eslint-plugin-next";
import unicornPlugin from "eslint-plugin-unicorn";
import prettierRecommended from "eslint-plugin-prettier/recommended";
import { FlatCompat } from "@eslint/eslintrc";
import { fileURLToPath } from "url";
import { dirname } from "path";
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}"],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
plugins: {
"@next/next": nextPlugin,
},
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": "warn",
"unicorn/filename-case": "off",
"unicorn/no-null": "warn",
"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",
},
},
prettierRecommended,
];
export default eslintConfig;