diff --git a/.eslintrc.json b/.eslintrc.json index 987032c5..1805d0c8 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -86,6 +86,10 @@ "assertionStyle": "never" } ], + "@typescript-eslint/consistent-type-definitions": [ + "error", + "interface" + ], "@typescript-eslint/no-shadow": [ "error" ], diff --git a/.projenrc.ts b/.projenrc.ts index 2db6c455..32e10e55 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -1,3 +1,4 @@ +import type {Linter} from 'eslint' import {readFileSync} from 'fs' import * as projen from 'projen' import {addHusky} from './src/common/git' @@ -64,10 +65,15 @@ project.package.addField('version', version) project.package.addField('overrides', {'@types/babel__traverse': 'ts3.9'}) // ANCHOR ESLint and prettier setup +const rules: Linter.RulesRecord = { + 'import/no-relative-parent-imports': ['off'], // Relative paths are required at runtime + '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], // JSII requires interfaces to be exported +} + addLinters({ project, lintPaths: ['.projenrc.ts', 'src'], - extraEslintConfigs: [{rules: {'import/no-relative-parent-imports': ['off']}}], + extraEslintConfigs: [{rules}], }) // Solves the typescript > 4 problem diff --git a/src/apollo-server/__tests__/__snapshots__/index.ts.snap b/src/apollo-server/__tests__/__snapshots__/index.ts.snap index c5aa55a7..2cfd5112 100644 --- a/src/apollo-server/__tests__/__snapshots__/index.ts.snap +++ b/src/apollo-server/__tests__/__snapshots__/index.ts.snap @@ -155,6 +155,10 @@ ACCESS_TOKEN=5aff40b2312321laksdkncKSDA "assertionStyle": "never", }, ], + "@typescript-eslint/consistent-type-definitions": [ + "error", + "type", + ], "@typescript-eslint/no-shadow": [ "error", ], diff --git a/src/cdk/__tests__/__snapshots__/index.ts.snap b/src/cdk/__tests__/__snapshots__/index.ts.snap index 539ccc82..f7c5301b 100644 --- a/src/cdk/__tests__/__snapshots__/index.ts.snap +++ b/src/cdk/__tests__/__snapshots__/index.ts.snap @@ -139,6 +139,10 @@ exports[`CDK template sets defaults 1`] = ` "assertionStyle": "never", }, ], + "@typescript-eslint/consistent-type-definitions": [ + "error", + "type", + ], "@typescript-eslint/no-shadow": [ "error", ], diff --git a/src/common/lint/add-linters.ts b/src/common/lint/add-linters.ts index ab041ae0..f75cb38a 100644 --- a/src/common/lint/add-linters.ts +++ b/src/common/lint/add-linters.ts @@ -10,7 +10,7 @@ import {prettierConfig} from './configs/prettier' const arrayEslintConfigProperties = ['extends', 'overrides', 'plugins'] as const type LinterConfigArrayProperties = Pick -type AddLintersProps = { +interface AddLintersProps { readonly project: NodeProject readonly lintPaths: Array readonly extraEslintConfigs?: Array diff --git a/src/common/lint/configs/cspell.ts b/src/common/lint/configs/cspell.ts index e84e61c6..6f9892c7 100644 --- a/src/common/lint/configs/cspell.ts +++ b/src/common/lint/configs/cspell.ts @@ -1,9 +1,9 @@ -type DictionaryDefinition = { +interface DictionaryDefinition { name: string path: string } -type LanguageSettings = { +interface LanguageSettings { /** * VSCode languageId. i.e. typescript, java, go, cpp, javascript, markdown, latex * will match against any file type. @@ -30,7 +30,7 @@ type LanguageSettings = { } /** @see https://cspell.org/configuration/#cspelljson-sections */ -type CSpellConfig = { +interface CSpellConfig { /** Currently always 0.2 - controls how the settings in the configuration file behave. */ version: string diff --git a/src/common/lint/configs/eslint-config-quality.ts b/src/common/lint/configs/eslint-config-quality.ts index 547628a3..464112d9 100644 --- a/src/common/lint/configs/eslint-config-quality.ts +++ b/src/common/lint/configs/eslint-config-quality.ts @@ -33,6 +33,7 @@ export const eslintConfigQuality: Linter.Config = { {'ts-expect-error': 'allow-with-description', 'ts-ignore': 'allow-with-description'}, ], '@typescript-eslint/consistent-type-assertions': ['error', {assertionStyle: 'never'}], + '@typescript-eslint/consistent-type-definitions': ['error', 'type'], '@typescript-eslint/no-shadow': ['error'], '@typescript-eslint/no-unused-expressions': ['error'], '@typescript-eslint/no-unused-vars': ['error', {argsIgnorePattern: '^_'}], diff --git a/src/nextjs/__tests__/__snapshots__/index.ts.snap b/src/nextjs/__tests__/__snapshots__/index.ts.snap index b3b3c71c..488c70f6 100644 --- a/src/nextjs/__tests__/__snapshots__/index.ts.snap +++ b/src/nextjs/__tests__/__snapshots__/index.ts.snap @@ -149,6 +149,10 @@ node_modules "assertionStyle": "never", }, ], + "@typescript-eslint/consistent-type-definitions": [ + "error", + "type", + ], "@typescript-eslint/no-shadow": [ "error", ], diff --git a/src/sst/__tests__/__snapshots__/index.ts.snap b/src/sst/__tests__/__snapshots__/index.ts.snap index 98f74450..4452d81e 100644 --- a/src/sst/__tests__/__snapshots__/index.ts.snap +++ b/src/sst/__tests__/__snapshots__/index.ts.snap @@ -139,6 +139,10 @@ exports[`SST template sets defaults 1`] = ` "assertionStyle": "never", }, ], + "@typescript-eslint/consistent-type-definitions": [ + "error", + "type", + ], "@typescript-eslint/no-shadow": [ "error", ],