eslint/rules/objects-and-collections
Objects and collections: Object literals, properties, Map and Set. Rules of ESLint, typescript-eslint and SonarJS (the Sonar way profile of SonarQube) on this subject, every rule listed; the TypeScript rules apply to TypeScript files only.
17 rules, 14 on. Source: lint/eslint/rules/objects-and-collections.mjs.
| Rule | Setting | Files | What it checks | Why |
|---|---|---|---|---|
no-dupe-keys | error | JS + TS | Disallow duplicate keys in object literals | — |
dot-notation | error | JS + TS | Enforce dot notation whenever possible | Replaced by the TS version. |
no-proto | error | JS + TS | Disallow the use of the __proto__ property | — |
no-useless-computed-key | error | JS + TS | Disallow unnecessary computed property keys in objects and classes | — |
object-shorthand | error | JS + TS | Require or disallow method and property shorthand syntax for object literals | — |
prefer-object-has-own | error | JS + TS | Disallow use of Object.prototype.hasOwnProperty.call() and prefer use of Object.hasOwn() | — |
prefer-object-spread | error | JS + TS | Disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead | — |
sonarjs/prefer-object-literal | off | JS + TS | Object literal syntax should be used | Off: not in the Sonar way profile of SonarQube. |
sonarjs/avoid-mutating-nested-properties-of-shallow-clones | warn | JS + TS | Nested properties of Lodash and Underscore.js clone results should not be mutated | — |
sonarjs/memoize-cache-key | warn | JS + TS | Lodash and Underscore.js memoize calls on functions with multiple parameters should use an explicit cache key function | — |
sonarjs/no-collection-size-mischeck | error | JS + TS | Collection size and array length comparisons should make sense | — |
sonarjs/no-empty-collection | error | JS + TS | Empty collections should not be accessed or iterated | — |
sonarjs/no-unused-collection | error | JS + TS | Collection contents should be used | — |
no-dupe-keys | off | TS | Disallow duplicate keys in object literals | — |
@typescript-eslint/consistent-indexed-object-style | error | TS | Require or disallow the Record type | — |
dot-notation | off | TS | Enforce dot notation whenever possible | Replaced by the TS version. |
@typescript-eslint/dot-notation | error | TS | Enforce dot notation whenever possible | — |