Major refactoring using ESLint with rules from AirBnb and Vue. Enable most of the ESLint rules and do necessary linting in the code. Also add more information for rules that are disabled to describe what they are and why they are disabled. Allow logging (`console.log`) in test files, and in development mode (e.g. when working with `npm run serve`), but disable it when environment is production (as pre-configured by Vue). Also add flag (`--mode production`) in `lint:eslint` command so production linting is executed earlier in lifecycle. Disable rules that requires a separate work. Such as ESLint rules that are broken in TypeScript: no-useless-constructor (eslint/eslint#14118) and no-shadow (eslint/eslint#13014).
37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
import { IApplicationCode } from '@/application/Context/State/Code/IApplicationCode';
|
|
import { IUserFilter } from '@/application/Context/State/Filter/IUserFilter';
|
|
import { ICategoryCollectionState } from '@/application/Context/State/ICategoryCollectionState';
|
|
import { OperatingSystem } from '@/domain/OperatingSystem';
|
|
import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript';
|
|
import { IScript } from '@/domain/IScript';
|
|
import { CategoryCollectionStub } from './CategoryCollectionStub';
|
|
import { UserSelectionStub } from './UserSelectionStub';
|
|
import { UserFilterStub } from './UserFilterStub';
|
|
import { ApplicationCodeStub } from './ApplicationCodeStub';
|
|
import { CategoryStub } from './CategoryStub';
|
|
|
|
export class CategoryCollectionStateStub implements ICategoryCollectionState {
|
|
public readonly code: IApplicationCode = new ApplicationCodeStub();
|
|
|
|
public readonly filter: IUserFilter = new UserFilterStub();
|
|
|
|
public readonly os = OperatingSystem.Windows;
|
|
|
|
public readonly collection: CategoryCollectionStub;
|
|
|
|
public readonly selection: UserSelectionStub;
|
|
|
|
constructor(readonly allScripts: IScript[]) {
|
|
this.selection = new UserSelectionStub(allScripts);
|
|
this.collection = new CategoryCollectionStub()
|
|
.withOs(this.os)
|
|
.withTotalScripts(this.allScripts.length)
|
|
.withAction(new CategoryStub(0).withScripts(...allScripts));
|
|
}
|
|
|
|
public withSelectedScripts(initialScripts: readonly SelectedScript[]) {
|
|
this.selection.withSelectedScripts(initialScripts);
|
|
return this;
|
|
}
|
|
}
|