diff --git a/packages/eslint-plugin/src/rules/array-type.ts b/packages/eslint-plugin/src/rules/array-type.ts index e6e78b6e0f4d..1e3b978a2813 100644 --- a/packages/eslint-plugin/src/rules/array-type.ts +++ b/packages/eslint-plugin/src/rules/array-type.ts @@ -112,6 +112,7 @@ export default util.createRule({ enum: ['array', 'generic', 'array-simple'], }, }, + additionalProperties: false, properties: { default: { $ref: '#/items/0/$defs/arrayOption', diff --git a/packages/eslint-plugin/src/rules/ban-ts-comment.ts b/packages/eslint-plugin/src/rules/ban-ts-comment.ts index 2c2e68855056..f3622c693ac9 100644 --- a/packages/eslint-plugin/src/rules/ban-ts-comment.ts +++ b/packages/eslint-plugin/src/rules/ban-ts-comment.ts @@ -53,6 +53,7 @@ export default util.createRule<[Options], MessageIds>({ }, { type: 'object', + additionalProperties: false, properties: { descriptionFormat: { type: 'string' }, }, diff --git a/packages/eslint-plugin/src/rules/naming-convention-utils/schema.ts b/packages/eslint-plugin/src/rules/naming-convention-utils/schema.ts index 0d092ea871d1..2cb6d9fed62b 100644 --- a/packages/eslint-plugin/src/rules/naming-convention-utils/schema.ts +++ b/packages/eslint-plugin/src/rules/naming-convention-utils/schema.ts @@ -40,6 +40,7 @@ const $DEFS: Record = { }, matchRegexConfig: { type: 'object', + additionalProperties: false, properties: { match: { type: 'boolean' }, regex: { type: 'string' }, diff --git a/packages/eslint-plugin/src/rules/no-misused-promises.ts b/packages/eslint-plugin/src/rules/no-misused-promises.ts index 878a327982b1..3728d567621a 100644 --- a/packages/eslint-plugin/src/rules/no-misused-promises.ts +++ b/packages/eslint-plugin/src/rules/no-misused-promises.ts @@ -83,6 +83,7 @@ export default util.createRule({ schema: [ { type: 'object', + additionalProperties: false, properties: { checksConditionals: { type: 'boolean', diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts b/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts index 76fc59da74b2..589a257e572b 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts @@ -31,6 +31,7 @@ export default util.createRule({ schema: [ { type: 'object', + additionalProperties: false, properties: { typesToIgnore: { description: 'A list of type names to ignore.', diff --git a/packages/eslint-plugin/src/rules/require-array-sort-compare.ts b/packages/eslint-plugin/src/rules/require-array-sort-compare.ts index d38c032cb22b..f5628120c804 100644 --- a/packages/eslint-plugin/src/rules/require-array-sort-compare.ts +++ b/packages/eslint-plugin/src/rules/require-array-sort-compare.ts @@ -30,6 +30,7 @@ export default util.createRule({ schema: [ { type: 'object', + additionalProperties: false, properties: { ignoreStringArrays: { description: diff --git a/packages/eslint-plugin/src/rules/restrict-template-expressions.ts b/packages/eslint-plugin/src/rules/restrict-template-expressions.ts index e31807bfc1a8..32b670f47017 100644 --- a/packages/eslint-plugin/src/rules/restrict-template-expressions.ts +++ b/packages/eslint-plugin/src/rules/restrict-template-expressions.ts @@ -33,6 +33,7 @@ export default util.createRule({ schema: [ { type: 'object', + additionalProperties: false, properties: { allowNumber: { description: diff --git a/packages/eslint-plugin/src/rules/sort-type-constituents.ts b/packages/eslint-plugin/src/rules/sort-type-constituents.ts index 81af9b1d9ec5..ec54153e988d 100644 --- a/packages/eslint-plugin/src/rules/sort-type-constituents.ts +++ b/packages/eslint-plugin/src/rules/sort-type-constituents.ts @@ -124,6 +124,7 @@ export default util.createRule({ schema: [ { type: 'object', + additionalProperties: false, properties: { checkIntersections: { description: 'Whether to check intersection types.', diff --git a/packages/eslint-plugin/src/rules/typedef.ts b/packages/eslint-plugin/src/rules/typedef.ts index bc95283b78c6..51820a11ef95 100644 --- a/packages/eslint-plugin/src/rules/typedef.ts +++ b/packages/eslint-plugin/src/rules/typedef.ts @@ -31,6 +31,7 @@ export default util.createRule<[Options], MessageIds>({ schema: [ { type: 'object', + additionalProperties: false, properties: { [OptionKeys.ArrayDestructuring]: { type: 'boolean' }, [OptionKeys.ArrowParameter]: { type: 'boolean' }, diff --git a/packages/eslint-plugin/tests/schema-snapshots/array-type.shot b/packages/eslint-plugin/tests/schema-snapshots/array-type.shot index da76d7036a86..4fef7c8ec978 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/array-type.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/array-type.shot @@ -11,6 +11,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "enum": ["array", "array-simple", "generic"] } }, + "additionalProperties": false, "properties": { "default": { "$ref": "#/items/0/$defs/arrayOption", diff --git a/packages/eslint-plugin/tests/schema-snapshots/ban-ts-comment.shot b/packages/eslint-plugin/tests/schema-snapshots/ban-ts-comment.shot index e754ff98ae5d..ee076d804daa 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/ban-ts-comment.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/ban-ts-comment.shot @@ -17,6 +17,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos "enum": ["allow-with-description"] }, { + "additionalProperties": false, "properties": { "descriptionFormat": { "type": "string" diff --git a/packages/eslint-plugin/tests/schema-snapshots/naming-convention.shot b/packages/eslint-plugin/tests/schema-snapshots/naming-convention.shot index c97b0eefc220..1f360bc55c29 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/naming-convention.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/naming-convention.shot @@ -21,6 +21,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos ] }, "matchRegexConfig": { + "additionalProperties": false, "properties": { "match": { "type": "boolean" diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-misused-promises.shot b/packages/eslint-plugin/tests/schema-snapshots/no-misused-promises.shot index be4e2d561120..2ba6191f4645 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-misused-promises.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-misused-promises.shot @@ -6,6 +6,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos [ { + "additionalProperties": false, "properties": { "checksConditionals": { "type": "boolean" diff --git a/packages/eslint-plugin/tests/schema-snapshots/no-unnecessary-type-assertion.shot b/packages/eslint-plugin/tests/schema-snapshots/no-unnecessary-type-assertion.shot index 29683a8039ce..b0954ae493bc 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/no-unnecessary-type-assertion.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/no-unnecessary-type-assertion.shot @@ -6,6 +6,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos [ { + "additionalProperties": false, "properties": { "typesToIgnore": { "description": "A list of type names to ignore.", diff --git a/packages/eslint-plugin/tests/schema-snapshots/require-array-sort-compare.shot b/packages/eslint-plugin/tests/schema-snapshots/require-array-sort-compare.shot index 938d7b6887a3..979a80507162 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/require-array-sort-compare.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/require-array-sort-compare.shot @@ -6,6 +6,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos [ { + "additionalProperties": false, "properties": { "ignoreStringArrays": { "description": "Whether to ignore arrays in which all elements are strings.", diff --git a/packages/eslint-plugin/tests/schema-snapshots/restrict-template-expressions.shot b/packages/eslint-plugin/tests/schema-snapshots/restrict-template-expressions.shot index a5af1c8d0630..194ddc4260cb 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/restrict-template-expressions.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/restrict-template-expressions.shot @@ -6,6 +6,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos [ { + "additionalProperties": false, "properties": { "allowAny": { "description": "Whether to allow \`any\` typed values in template expressions.", diff --git a/packages/eslint-plugin/tests/schema-snapshots/sort-type-constituents.shot b/packages/eslint-plugin/tests/schema-snapshots/sort-type-constituents.shot index d84cff0e09d6..3384c8b4d50e 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/sort-type-constituents.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/sort-type-constituents.shot @@ -6,6 +6,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos [ { + "additionalProperties": false, "properties": { "checkIntersections": { "description": "Whether to check intersection types.", diff --git a/packages/eslint-plugin/tests/schema-snapshots/typedef.shot b/packages/eslint-plugin/tests/schema-snapshots/typedef.shot index d08f373ab797..e244ad4d80ca 100644 --- a/packages/eslint-plugin/tests/schema-snapshots/typedef.shot +++ b/packages/eslint-plugin/tests/schema-snapshots/typedef.shot @@ -6,6 +6,7 @@ exports[`Rule schemas should be convertible to TS types for documentation purpos [ { + "additionalProperties": false, "properties": { "arrayDestructuring": { "type": "boolean" diff --git a/packages/rule-schema-to-typescript-types/src/generateObjectType.ts b/packages/rule-schema-to-typescript-types/src/generateObjectType.ts index 9ff4b928dcd7..c0de43699d36 100644 --- a/packages/rule-schema-to-typescript-types/src/generateObjectType.ts +++ b/packages/rule-schema-to-typescript-types/src/generateObjectType.ts @@ -13,13 +13,16 @@ export function generateObjectType( const commentLines = getCommentLines(schema); let indexSignature: AST | null = null; - if (schema.additionalProperties === true) { + if ( + schema.additionalProperties === true || + schema.additionalProperties === undefined + ) { indexSignature = { type: 'type-reference', typeName: 'unknown', commentLines: [], }; - } else if (schema.additionalProperties) { + } else if (typeof schema.additionalProperties === 'object') { const indexSigType = generateType(schema.additionalProperties, refMap); indexSignature = indexSigType; }