no-var
eslint
Safe autofix
eslint.config.js
export default [
{
rules: {
"no-var": "error",
},
},
];var x = "y";
var CONFIG = {};declare var x: number
declare namespace ns {
var x: number
}
declare module 'module' {
var x: number
}let x = "y";
const CONFIG = {};declare global {
declare var x: number
}Examples from the ESLint documentation.
no-var
eslint
export default [
{
rules: {
"no-var": "error",
},
},
];no-var
eslint plugin · restriction
{
"rules": {
"no-var": "error"
}
}suspicious/noVar
suspicious · since 1.0.0
{
"linter": {
"rules": {
"suspicious": {
"noVar": "error"
}
}
}
}Disallow the use of undeclared variables unless mentioned in /*global */ comments
Disallow confusing multiline expressions
Require spread operators instead of .apply()
Disallow losing originally caught error when re-throwing custom errors
Disallow variable assignments when the value is not used