# no-empty-after-reluctant

Rule `sonarjs/no-empty-after-reluctant`. Reluctant quantifiers in regular expressions should be followed by an expression that can't match the empty string

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: yes
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1259 by reach, #560 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/no-empty-after-reluctant` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-6019/) |

## Code examples

### Incorrect: the rule reports this

```js
str.split(/.*?x?/); // Noncompliant, this will behave just like "x?"
/^.*?$/.test(str); // Noncompliant, replace with ".*"
```

### Correct: the rule accepts this

```js
str.split(/.*?x/);
/^.*$/.test(str);
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/no-empty-after-reluctant": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/no-element-overwrite](https://lintradar.dev/rules/sonarjs/no-element-overwrite.md): Collection elements should not be replaced unconditionally
- [sonarjs/no-empty-alternatives](https://lintradar.dev/rules/sonarjs/no-empty-alternatives.md): Alternation in regular expressions should not contain empty alternatives
- [sonarjs/no-duplicated-branches](https://lintradar.dev/rules/sonarjs/no-duplicated-branches.md): Two branches in a conditional structure should not have exactly the same implementation
- [sonarjs/no-empty-character-class](https://lintradar.dev/rules/sonarjs/no-empty-character-class.md): Empty character classes should not be used
- [sonarjs/no-duplicate-test-title](https://lintradar.dev/rules/sonarjs/no-duplicate-test-title.md): Test titles should be unique within the same suite
- [sonarjs/no-empty-collection](https://lintradar.dev/rules/sonarjs/no-empty-collection.md): Empty collections should not be accessed or iterated

---

Web page: https://lintradar.dev/rules/sonarjs/no-empty-after-reluctant. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
