Skip to content

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.

RuleSettingFilesWhat it checksWhy
no-dupe-keyserrorJS + TSDisallow duplicate keys in object literals—
dot-notationerrorJS + TSEnforce dot notation whenever possibleReplaced by the TS version.
no-protoerrorJS + TSDisallow the use of the __proto__ property—
no-useless-computed-keyerrorJS + TSDisallow unnecessary computed property keys in objects and classes—
object-shorthanderrorJS + TSRequire or disallow method and property shorthand syntax for object literals—
prefer-object-has-ownerrorJS + TSDisallow use of Object.prototype.hasOwnProperty.call() and prefer use of Object.hasOwn()—
prefer-object-spreaderrorJS + TSDisallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead—
sonarjs/prefer-object-literaloffJS + TSObject literal syntax should be usedOff: not in the Sonar way profile of SonarQube.
sonarjs/avoid-mutating-nested-properties-of-shallow-cloneswarnJS + TSNested properties of Lodash and Underscore.js clone results should not be mutated—
sonarjs/memoize-cache-keywarnJS + TSLodash and Underscore.js memoize calls on functions with multiple parameters should use an explicit cache key function—
sonarjs/no-collection-size-mischeckerrorJS + TSCollection size and array length comparisons should make sense—
sonarjs/no-empty-collectionerrorJS + TSEmpty collections should not be accessed or iterated—
sonarjs/no-unused-collectionerrorJS + TSCollection contents should be used—
no-dupe-keysoffTSDisallow duplicate keys in object literals—
@typescript-eslint/consistent-indexed-object-styleerrorTSRequire or disallow the Record type—
dot-notationoffTSEnforce dot notation whenever possibleReplaced by the TS version.
@typescript-eslint/dot-notationerrorTSEnforce dot notation whenever possible—

Generated from the JSDoc of the sources.