# require-atomic-updates

Rule `eslint/require-atomic-updates`. Disallow assignments that can lead to race conditions due to usage of `await` or `yield`

- Source: eslint
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 171.7K weekly downloads of presets that enable it
- Trend: +39.3% last quarter
- Rank: #1637 by reach, #1027 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `require-atomic-updates` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/require-atomic-updates) |
| Biome | `nursery/useAtomicUpdates` | no | no | group nursery, since 2.6.7 | [docs](https://biomejs.dev/linter/rules/use-atomic-updates/) |

## Code examples

### Incorrect: the rule reports this

```js
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;
}
```

```js
async function foo(obj) {
    if (!obj.done) {
        obj.something = await getSomething();
    }
}
```

### Correct: the rule accepts this

```js
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;
}
```

```js
async function foo(obj) {
    if (!obj.done) {
        const tmp = await getSomething();
        if (!obj.done) {
            obj.something = tmp;
        }
    }
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "require-atomic-updates": "error",
    },
  },
];
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "useAtomicUpdates": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [eslint/init-declarations](https://lintradar.dev/rules/eslint/init-declarations.md): Require or disallow initialization in variable declarations
- [eslint/max-lines-per-function](https://lintradar.dev/rules/eslint/max-lines-per-function.md): Enforce a maximum number of lines of code in a function
- [eslint/max-statements](https://lintradar.dev/rules/eslint/max-statements.md): Enforce a maximum number of statements allowed in function blocks
- [eslint/no-magic-numbers](https://lintradar.dev/rules/eslint/no-magic-numbers.md): Disallow magic numbers
- [eslint/no-ternary](https://lintradar.dev/rules/eslint/no-ternary.md): Disallow ternary operators
- [eslint/capitalized-comments](https://lintradar.dev/rules/eslint/capitalized-comments.md): Enforce or disallow capitalization of the first letter of a comment

---

Web page: https://lintradar.dev/rules/eslint/require-atomic-updates. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
