no-inline-comments
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"no-inline-comments": "error",
},
},
];const a = 1; // declaring a to 1
function getRandomNumber(){
return 4; // chosen by fair dice roll.
// guaranteed to be random.
}
/* A block comment before code */ const b = 2;
const c = 3; /* A block comment after code */const foo = <div>{ /* On the same line with other code */ }<h1>Some heading</h1></div>;
const bar = (
<div>
{ // These braces are not just for the comment, so it can't be on the same line
baz
}
</div>
);// This is a comment above a line of code
const foo = 5;
const bar = 5;
//This is a comment below a line of codeconst foo = (
<div>
{/* These braces are just for this comment and there is nothing else on this line */}
<h1>Some heading</h1>
</div>
)
const bar = (
<div>
{
// There is nothing else on this line
baz
}
</div>
);
const quux = (
<div>
{/*
Multiline
comment
*/}
<h1>Some heading</h1>
</div>
)Examples from the ESLint documentation.
no-inline-comments
eslint
export default [
{
rules: {
"no-inline-comments": "error",
},
},
];no-inline-comments
eslint plugin · pedantic
{
"rules": {
"no-inline-comments": "error"
}
}Biome does not have this rule.
Require variables within the same declaration block to be sorted
Require identifiers to match a specified regular expression
Enforce the consistent use of either function declarations or expressions assigned to variables
Disallow async functions which have no await expression