# inconsistent-function-call

Rule `sonarjs/inconsistent-function-call`. Functions should be called consistently with or without "new"

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

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/inconsistent-function-call` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-3686/) |

## Code examples

### Incorrect: the rule reports this

```js
function getNum() {
  return 5;
}

function Num(numeric, alphabetic) {
  this.numeric = numeric;
  this.alphabetic = alphabetic;
}

var myFirstNum = getNum();
var my2ndNum = new getNum();  // Noncompliant. An empty object is returned, NOT 5

var myNumObj1 = new Num();
var myNumObj2 = Num();  // Noncompliant. undefined is returned, NOT an object
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/inconsistent-function-call": "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/in-operator-type-error](https://lintradar.dev/rules/sonarjs/in-operator-type-error.md): "in" should not be used with primitive types
- [sonarjs/index-of-compare-to-positive-number](https://lintradar.dev/rules/sonarjs/index-of-compare-to-positive-number.md): "indexOf" checks should not be for positive numbers
- [sonarjs/hooks-before-test-cases](https://lintradar.dev/rules/sonarjs/hooks-before-test-cases.md): Lifecycle hooks should not be interleaved with test cases or nested suites
- [sonarjs/insecure-cookie](https://lintradar.dev/rules/sonarjs/insecure-cookie.md): Cookies should have the "secure" flag
- [sonarjs/hashing](https://lintradar.dev/rules/sonarjs/hashing.md): Weak hashing algorithms should not be used
- [sonarjs/insecure-jwt-token](https://lintradar.dev/rules/sonarjs/insecure-jwt-token.md): JWT should be signed and verified with strong cipher algorithms

---

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