require-atomic-updates
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"require-atomic-updates": "error",
},
},
];Disallow assignments that can lead to race conditions due to usage of await or yield
let result;
async function foo() {
result += await something;
}
async function bar() {
result = result + await something;
}
async function baz() {
result = result + doSomething(await somethingElse);
}
async function qux() {
if (!result) {
result = await initialize();
}
}
function* generator() {
result += yield;
}async function foo(obj) {
if (!obj.done) {
obj.something = await getSomething();
}
}let result;
async function foobar() {
result = await something + result;
}
async function baz() {
const tmp = doSomething(await somethingElse);
result += tmp;
}
async function qux() {
if (!result) {
const tmp = await initialize();
if (!result) {
result = tmp;
}
}
}
async function quux() {
let localVariable = 0;
localVariable += await something;
}
function* generator() {
result = (yield) + result;
}async function foo(obj) {
if (!obj.done) {
const tmp = await getSomething();
if (!obj.done) {
obj.something = tmp;
}
}
}Examples from the ESLint documentation.
require-atomic-updates
eslint
export default [
{
rules: {
"require-atomic-updates": "error",
},
},
];Oxlint does not have this rule.
nursery/useAtomicUpdates
nursery · since 2.6.7
{
"linter": {
"rules": {
"nursery": {
"useAtomicUpdates": "error"
}
}
}
}Require or disallow initialization in variable declarations
Enforce a maximum number of lines of code in a function
Enforce a maximum number of statements allowed in function blocks
Enforce or disallow capitalization of the first letter of a comment