This introduces a flat ESLint configuration for JavaScript, MJS, and CJS files, including recommended rules and global variables for both browser and Node.js environments.
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
// ESLint 9+ flat config format (global default)
|
|
// See: https://eslint.org/docs/latest/use/configure/configuration-files
|
|
|
|
export default [
|
|
{
|
|
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
|
|
languageOptions: {
|
|
ecmaVersion: "latest",
|
|
sourceType: "module",
|
|
globals: {
|
|
// Browser globals
|
|
console: "readonly",
|
|
window: "readonly",
|
|
document: "readonly",
|
|
navigator: "readonly",
|
|
// Node.js globals
|
|
process: "readonly",
|
|
__dirname: "readonly",
|
|
__filename: "readonly",
|
|
require: "readonly",
|
|
module: "readonly",
|
|
exports: "readonly",
|
|
global: "readonly",
|
|
Buffer: "readonly",
|
|
},
|
|
},
|
|
rules: {
|
|
// Recommended rules
|
|
"no-undef": "error",
|
|
"no-unused-vars": "warn",
|
|
"no-unreachable": "warn",
|
|
"no-constant-condition": "error",
|
|
"no-duplicate-case": "error",
|
|
|
|
// Best practices
|
|
"eqeqeq": ["warn", "always"],
|
|
"no-implicit-globals": "warn",
|
|
|
|
// Style (minimal)
|
|
"semi": ["warn", "always"],
|
|
"quotes": ["warn", "double", { "avoidEscape": true }],
|
|
},
|
|
},
|
|
];
|