Update eslint config to flat config
This commit is contained in:
31
eslint.config.mjs
Normal file
31
eslint.config.mjs
Normal file
@@ -0,0 +1,31 @@
|
||||
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';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const compat = new FlatCompat({
|
||||
baseDirectory: __dirname,
|
||||
recommendedConfig: mjs.configs.recommended
|
||||
});
|
||||
|
||||
export default [
|
||||
...compat.extends().map(
|
||||
config => ({
|
||||
...config,
|
||||
files: ["**/*.mjs", "**/*.js", "**/*.cjs"],
|
||||
rules: {
|
||||
...config.rules,
|
||||
// ...other your custom rules
|
||||
"no-console": "warn",
|
||||
"no-unused-vars": "warn",
|
||||
"unused-imports/no-unused-imports": "error",
|
||||
}
|
||||
})
|
||||
),
|
||||
prettierConfig, // Turns off all ESLint rules that have the potential to interfere with Prettier rules.
|
||||
eslintPluginPrettierRecommended
|
||||
];
|
||||
Reference in New Issue
Block a user