Files
landing-for-digital-product/eslint.config.mjs
2025-12-01 23:11:50 +03:00

120 lines
4.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { dirname } from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
});
const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"),
{
ignores: [
"**/node_modules/**",
"**/.next/**",
"**/out/**",
"**/build/**",
"**/next-env.d.ts",
],
},
{
files: ["**/*.{ts,tsx,js,jsx}"],
rules: {
// TypeScript rules
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-unsafe-assignment": "error",
"@typescript-eslint/no-unsafe-member-access": "error",
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/no-unsafe-return": "error",
"@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/explicit-module-boundary-types": "warn",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/prefer-nullish-coalescing": "warn",
"@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/no-unnecessary-condition": "warn",
"@typescript-eslint/no-redundant-type-constituents": "error",
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-expect-error": "allow-with-description",
"ts-ignore": true,
"ts-nocheck": true,
"ts-check": false,
},
],
// Disable base rule as it conflicts with TypeScript version
"no-unused-vars": "off",
// React rules
"react/react-in-jsx-scope": "off", // Не нужно в Next.js
"react/prop-types": "off", // Используем TypeScript
"react/display-name": "warn",
"react/no-unescaped-entities": "error",
"react/no-unknown-property": "error",
"react/jsx-key": "error",
"react/jsx-no-duplicate-props": "error",
"react/jsx-no-undef": "error",
"react/jsx-uses-react": "off", // Не нужно в Next.js
"react/jsx-uses-vars": "error",
"react/no-array-index-key": "warn",
"react/no-danger": "warn",
"react/no-deprecated": "error",
"react/no-direct-mutation-state": "error",
"react/no-typos": "error",
"react/self-closing-comp": "warn",
// React Hooks rules
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
// General JavaScript/TypeScript rules
"no-console": ["warn", { allow: ["warn", "error", "log"] }],
"no-debugger": "error",
"no-alert": "warn",
"no-var": "error",
"prefer-const": "error",
"prefer-arrow-callback": "warn",
"no-duplicate-imports": "error",
"no-unreachable": "error",
"no-unused-expressions": "error",
"no-useless-return": "error",
"no-useless-escape": "error",
"no-constant-condition": "error",
"no-empty": "warn",
"no-extra-semi": "error",
"no-func-assign": "error",
"no-inner-declarations": "error",
"no-irregular-whitespace": "error",
"no-obj-calls": "error",
"no-sparse-arrays": "error",
"no-undef": "off", // TypeScript проверяет это
"no-unexpected-multiline": "error",
"no-unreachable-loop": "error",
"use-isnan": "error",
"valid-typeof": "error",
// Next.js specific (через next/core-web-vitals уже включены, но можно усилить)
"@next/next/no-html-link-for-pages": "error",
"@next/next/no-img-element": "warn",
},
},
];
export default eslintConfig;