61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
import { dirname } from "path";
|
|
import { fileURLToPath } from "url";
|
|
import { FlatCompat } from "@eslint/eslintrc";
|
|
import eslintPluginImport from "eslint-plugin-import";
|
|
import eslintPluginUnused from "eslint-plugin-unused-imports";
|
|
import eslintPluginSort from "eslint-plugin-simple-import-sort";
|
|
|
|
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"),
|
|
|
|
{
|
|
plugins: {
|
|
import: eslintPluginImport,
|
|
"unused-imports": eslintPluginUnused,
|
|
"simple-import-sort": eslintPluginSort,
|
|
},
|
|
|
|
rules: {
|
|
/* неиспользуемые переменные и импорты */
|
|
"@typescript-eslint/no-unused-vars": [
|
|
"error",
|
|
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
|
|
],
|
|
"unused-imports/no-unused-imports": "error",
|
|
"unused-imports/no-unused-vars": [
|
|
"warn",
|
|
{
|
|
vars: "all",
|
|
varsIgnorePattern: "^_",
|
|
args: "after-used",
|
|
argsIgnorePattern: "^_",
|
|
},
|
|
],
|
|
|
|
/* порядок импортов: стили .module.(s)css внизу */
|
|
"simple-import-sort/imports": [
|
|
"error",
|
|
{
|
|
groups: [
|
|
["^\\u0000"], // side-effects
|
|
["^react", "^next", "^@?\\w"],// пакеты
|
|
["^@/"], // алиасы проекта
|
|
["^\\.\\.(?!/?$)", "^\\./(?=.*/)", "^\\./?$"], // относительные
|
|
["^.+\\.module\\.(css|scss)$"], // модули стилей
|
|
],
|
|
},
|
|
],
|
|
"simple-import-sort/exports": "error",
|
|
},
|
|
},
|
|
];
|
|
|
|
export default eslintConfig;
|