# confidential-information-logging

Rule `sonarjs/confidential-information-logging`. Confidential information should not be logged

- Source: sonarjs
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Deprecated: yes
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #2127 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/confidential-information-logging` | no | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-5757/) |

## Code examples

### Correct: the rule accepts this

```js
const { Signale } = require('signale');

const CREDIT_CARD_NUMBERS = fetchFromWebForm()
// here we suppose the credit card numbers are retrieved somewhere and CREDIT_CARD_NUMBERS looks like ["1234-5678-0000-9999", "1234-5678-0000-8888"]; for instance

const options = {
  secrets: ["([0-9]{4}-?)+"]
};

const logger = new Signale(options); // Compliant

CREDIT_CARD_NUMBERS.forEach(function(CREDIT_CARD_NUMBER) {
  logger.log('The customer ordered products with the credit card number = %s', CREDIT_CARD_NUMBER);
});
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/confidential-information-logging": "error",
    },
  },
];
```

## Related rules

- [sonarjs/cyclomatic-complexity](https://lintradar.dev/rules/sonarjs/cyclomatic-complexity.md): Cyclomatic Complexity of functions should not be too high
- [sonarjs/composite-assertions](https://lintradar.dev/rules/sonarjs/composite-assertions.md): Composite assertions should be split
- [sonarjs/declarations-in-global-scope](https://lintradar.dev/rules/sonarjs/declarations-in-global-scope.md): Variables and functions should not be declared in the global scope
- [sonarjs/comment-regex](https://lintradar.dev/rules/sonarjs/comment-regex.md): Track comments matching a regular expression
- [sonarjs/destructuring-assignment-syntax](https://lintradar.dev/rules/sonarjs/destructuring-assignment-syntax.md): Destructuring syntax should be used for assignments
- [sonarjs/class-prototype](https://lintradar.dev/rules/sonarjs/class-prototype.md): Class methods should be used instead of "prototype" assignments

---

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