Update eslint config to flat config
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
// eslint.config.js (flat config)
|
||||
import configRecommended from "eslint-config-eslint";
|
||||
import configPrettier from "eslint-config-prettier";
|
||||
import pluginPrettier from "eslint-plugin-prettier";
|
||||
import globals from "globals";
|
||||
import unusedImports from "eslint-plugin-unused-imports";
|
||||
import js from "@eslint/js";
|
||||
|
||||
export default [
|
||||
{
|
||||
languageOptions: {
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
globals: {
|
||||
...globals.node,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"no-console": "warn",
|
||||
"no-unused-vars": "warn",
|
||||
"unused-imports/no-unused-imports": 1,
|
||||
},
|
||||
},
|
||||
js.configs.recommended,
|
||||
pluginPrettier.configs.recommended,
|
||||
configPrettier,
|
||||
unusedImports.configs.recommended,
|
||||
];
|
||||
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