# no-same-argument-assert

Rule `sonarjs/no-same-argument-assert`. Assertions should not be given twice the same argument

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

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/no-same-argument-assert` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-5863/) |

## Code examples

### Incorrect: the rule reports this

```js
const assert = require('chai').assert;

describe("test the same object", function() {
    it("uses chai 'assert'", function() {
        const expected = '1'
        const actual = (1).toString()
        assert.equal(actual, actual);  // Noncompliant
    });
});
```

### Correct: the rule accepts this

```js
const assert = require('chai').assert;

describe("test the same object", function() {
    it("uses chai 'assert'", function() {
        const expected = '1'
        const actual = (1).toString()
        assert.equal(actual, expected);
    });
});
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/no-same-argument-assert": "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-regex-spaces](https://lintradar.dev/rules/sonarjs/no-regex-spaces.md): Regular expressions should not contain multiple spaces
- [sonarjs/no-same-line-conditional](https://lintradar.dev/rules/sonarjs/no-same-line-conditional.md): Conditionals should start on new lines
- [sonarjs/no-referrer-policy](https://lintradar.dev/rules/sonarjs/no-referrer-policy.md): HTTP Referrer-Policy should not be set to an unsafe value
- [sonarjs/no-selector-parameter](https://lintradar.dev/rules/sonarjs/no-selector-parameter.md): Methods should not contain selector parameters
- [sonarjs/no-redundant-optional](https://lintradar.dev/rules/sonarjs/no-redundant-optional.md): Optional properties should not redundantly include 'undefined'
- [sonarjs/no-session-cookies-on-static-assets](https://lintradar.dev/rules/sonarjs/no-session-cookies-on-static-assets.md): Static Assets should not serve session cookies

---

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