Skip to content

Commit

Permalink
Merge pull request #385 from ottofeller/add-eslint-rule-consistent-ty…
Browse files Browse the repository at this point in the history
…pe-definitions

PLA-267 Add eslint rule consistent-type-definitions
  • Loading branch information
quesabe authored Sep 30, 2023
2 parents dbb793f + 66bbe7b commit 1c2db00
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion .projenrc.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type {Linter} from 'eslint'
import {readFileSync} from 'fs'
import * as projen from 'projen'
import {addHusky} from './src/common/git'
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/apollo-server/__tests__/__snapshots__/index.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/cdk/__tests__/__snapshots__/index.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/common/lint/add-linters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {prettierConfig} from './configs/prettier'
const arrayEslintConfigProperties = ['extends', 'overrides', 'plugins'] as const
type LinterConfigArrayProperties = Pick<Linter.Config, (typeof arrayEslintConfigProperties)[number]>

type AddLintersProps = {
interface AddLintersProps {
readonly project: NodeProject
readonly lintPaths: Array<string>
readonly extraEslintConfigs?: Array<Linter.Config>
Expand Down
6 changes: 3 additions & 3 deletions src/common/lint/configs/cspell.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/common/lint/configs/eslint-config-quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '^_'}],
Expand Down
4 changes: 4 additions & 0 deletions src/nextjs/__tests__/__snapshots__/index.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/sst/__tests__/__snapshots__/index.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1c2db00

Please sign in to comment.