diff --git a/packages/eslint-plugin/src/rules/array-type.ts b/packages/eslint-plugin/src/rules/array-type.ts index e6e78b6e0f4..1e3b978a281 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 2c2e6885505..f3622c693ac 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 0d092ea871d..2cb6d9fed62 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 878a327982b..3728d567621 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 76fc59da74b..589a257e572 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 d38c032cb22..f5628120c80 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 e31807bfc1a..32b670f4701 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 81af9b1d9ec..ec54153e988 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 bc95283b78c..51820a11ef9 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 da76d7036a8..4fef7c8ec97 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 e754ff98ae5..ee076d804da 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 c97b0eefc22..1f360bc55c2 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 be4e2d56112..2ba6191f464 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 29683a8039c..b0954ae493b 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 938d7b6887a..979a8050716 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 a5af1c8d063..194ddc4260c 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 d84cff0e09d..3384c8b4d50 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 d08f373ab79..e244ad4d80c 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 9ff4b928dcd..c0de43699d3 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; }