Add ESLint configuration for JavaScript files
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.
This commit is contained in:
parent
949cc32d0b
commit
8a24bbb656
|
|
@ -0,0 +1,44 @@
|
|||
// 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 }],
|
||||
},
|
||||
},
|
||||
];
|
||||
Loading…
Reference in New Issue