Add AirBnb TypeScript overrides for linting

AirBnb only imports JavaScript rules and some fail for TypeScript files.
This commit overrides those rules with TypeScript equivalents.

Changes here can be mostly replaced when Vue natively support TypeScript
for Airbnb (vuejs/eslint-config-airbnb#23).

Enables @typescript-eslint/indent even though it's broken and it will
not be fixed typescript-eslint/typescript-eslint#1824 until prettifier
is used, because it is still useful.

Change broken rules with TypeScript variants:
  - `no-useless-constructor`
      eslint/eslint#14118
      typescript-eslint/typescript-eslint#873
  - `no-shadow`
      eslint/eslint#13044
      typescript-eslint/typescript-eslint#2483
      typescript-eslint/typescript-eslint#325
      typescript-eslint/typescript-eslint#2552
      typescript-eslint/typescript-eslint#2484
      typescript-eslint/typescript-eslint#2466
This commit is contained in:
undergroundwires
2022-01-19 22:28:33 +01:00
parent 2354f0ba9f
commit 834ce8cf9e
12 changed files with 193 additions and 18 deletions

View File

@@ -1,6 +1,6 @@
import 'mocha';
import { expect } from 'chai';
import { ApplicationFactory, ApplicationGetter } from '@/application/ApplicationFactory';
import { ApplicationFactory, ApplicationGetterType } from '@/application/ApplicationFactory';
import { ApplicationStub } from '@tests/unit/stubs/ApplicationStub';
describe('ApplicationFactory', () => {
@@ -19,7 +19,7 @@ describe('ApplicationFactory', () => {
it('returns result from the getter', async () => {
// arrange
const expected = new ApplicationStub();
const getter: ApplicationGetter = () => expected;
const getter: ApplicationGetterType = () => expected;
const sut = new SystemUnderTest(getter);
// act
const actual = await Promise.all([
@@ -35,7 +35,7 @@ describe('ApplicationFactory', () => {
// arrange
let totalExecution = 0;
const expected = new ApplicationStub();
const getter: ApplicationGetter = () => {
const getter: ApplicationGetterType = () => {
totalExecution++;
return expected;
};
@@ -54,7 +54,7 @@ describe('ApplicationFactory', () => {
});
class SystemUnderTest extends ApplicationFactory {
public constructor(costlyGetter: ApplicationGetter) {
public constructor(costlyGetter: ApplicationGetterType) {
super(costlyGetter);
}
}

View File

@@ -138,8 +138,8 @@ describe('ApplicationParser', () => {
class CategoryCollectionParserSpy {
public arguments = new Array<{
data: CollectionData,
info: ProjectInformation,
data: CollectionData,
info: ProjectInformation,
}>();
private returnValues = new Map<CollectionData, ICategoryCollection>();

View File

@@ -42,7 +42,7 @@ class SchedulerMock {
private currentTime = 0;
private scheduledActions = new Array<{time: number, action: SchedulerCallbackType}>();
private scheduledActions = new Array<{ time: number, action: SchedulerCallbackType }>();
constructor() {
this.mock = (callback: SchedulerCallbackType, ms: number) => {

View File

@@ -3,7 +3,7 @@ import { ICodeSubstituter } from '@/application/Parser/ScriptingDefinition/ICode
export class CodeSubstituterStub implements ICodeSubstituter {
private readonly scenarios =
new Array<{ code: string, info: IProjectInformation, result: string}>();
new Array<{ code: string, info: IProjectInformation, result: string }>();
public substitute(code: string, info: IProjectInformation): string {
const scenario = this.scenarios.find((s) => s.code === code && s.info === info);

View File

@@ -2,7 +2,7 @@ import { IEnumParser } from '@/application/Common/Enum';
export class EnumParserStub<T> implements IEnumParser<T> {
private readonly scenarios =
new Array<{ inputName: string, inputValue: string, outputValue: T }>();
new Array<{ inputName: string, inputValue: string, outputValue: T }>();
private defaultValue: T;

View File

@@ -6,7 +6,7 @@ import { FunctionCallArgumentCollectionStub } from '@tests/unit/stubs/FunctionCa
export class ExpressionsCompilerStub implements IExpressionsCompiler {
public readonly callHistory =
new Array<{ code: string, parameters: IReadOnlyFunctionCallArgumentCollection }>();
new Array<{ code: string, parameters: IReadOnlyFunctionCallArgumentCollection }>();
private readonly scenarios = new Array<ITestScenario>();

View File

@@ -6,7 +6,7 @@ import { EventSource } from '@/infrastructure/Events/EventSource';
export class UserSelectionStub implements IUserSelection {
public readonly changed: IEventSource<readonly SelectedScript[]> =
new EventSource<readonly SelectedScript[]>();
new EventSource<readonly SelectedScript[]>();
public selectedScripts: readonly SelectedScript[] = [];