48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
import { FlatCompat } from "@eslint/eslintrc";
|
|
import mjs from "@eslint/js";
|
|
import prettierConfig from "eslint-config-prettier";
|
|
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
|
|
import unusedImports from "eslint-plugin-unused-imports";
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
const compat = new FlatCompat({
|
|
baseDirectory: __dirname,
|
|
recommendedConfig: mjs.configs.recommended,
|
|
});
|
|
|
|
export default [
|
|
// Apply ESLint recommended settings first
|
|
...compat.extends().map((config) => ({
|
|
...config,
|
|
files: ["src/**/*.mjs", "src/**/*.js", "src/**/*.cjs"],
|
|
})),
|
|
|
|
// Custom rules and plugin configuration
|
|
{
|
|
plugins: {
|
|
"unused-imports": unusedImports,
|
|
},
|
|
rules: {
|
|
// Custom rules here
|
|
"no-console": "warn",
|
|
"no-unused-vars": "off", // or "@typescript-eslint/no-unused-vars": "off",
|
|
"unused-imports/no-unused-imports": "error",
|
|
"unused-imports/no-unused-vars": [
|
|
"warn",
|
|
{
|
|
vars: "all",
|
|
varsIgnorePattern: "^_",
|
|
args: "after-used",
|
|
argsIgnorePattern: "^_",
|
|
},
|
|
],
|
|
"prettier/prettier": "warn", // Integrate prettier
|
|
},
|
|
},
|
|
prettierConfig, // Turns off all ESLint rules that have the potential to interfere with Prettier rules.
|
|
eslintPluginPrettierRecommended,
|
|
];
|