Before:
class Car {
private _engine: Engine;
private _radio: Radio;
constructor () {
this._engine = new Engine();
this._radio = new Radio();
| import { NgModule } from '@angular/core'; | |
| import { RouterModule } from '@angular/router'; | |
| @NgModule({ | |
| imports: [ | |
| RouterModule.forChild([{ | |
| path: '', | |
| loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule) | |
| }]) | |
| ] |
| import { NgModule } from '@angular/core'; | |
| import { RouterModule } from '@angular/router'; | |
| @NgModule({ | |
| imports: [ | |
| RouterModule.forChild([{ | |
| path: '', | |
| loadChildren: './lazy/lazy.module#LazyModule' | |
| }]) | |
| ] |
Before:
class Car {
private _engine: Engine;
private _radio: Radio;
constructor () {
this._engine = new Engine();
this._radio = new Radio();
| // Dependencies: | |
| import { tsquery } from '@phenomnomnominal/tsquery'; | |
| import { RuleFailure, Rules } from 'tslint'; | |
| import { SourceFile } from 'typescript'; | |
| // Constants: | |
| const CATCH_ERROR_QUERY = 'ClassDeclaration > PropertyDeclaration:has(Decorator Identifier[name="Effect"]) > CallExpression > CallExpression > Identifier[name="catchError"]'; | |
| const FAILURE_MESSAGE = ` |
| it(`should not create a lint error if the Effect chain doesn't use "catchError()"`, () => { | |
| const sourceFile = tsquery.ast(` | |
| export class MyEffects { | |
| @Effect() | |
| public myEffect = something.observable$.pipe( | |
| switchMap(() => {}) | |
| ); | |
| }; | |
| `); |
| it(`should not create a lint error if the Effect chain doesn't use "catchError()"`, () => { | |
| const sourceFile = tsquery.ast(` | |
| export class MyEffects { | |
| @Effect() | |
| public myEffect = something.observable$.pipe( | |
| switchMap(() => {}) | |
| ); | |
| }; | |
| `); |
| import { tsquery } from '@phenomnomnominal/tsquery'; | |
| import { expect } from 'chai'; | |
| import { Rule } from './noCatchErrorInEffectChainRule'; | |
| describe('noCatchErrorInEffectChainRule', () => { | |
| it('should create a lint error if "catchError()" is in an Effect chain', () => { | |
| const sourceFile = tsquery.ast(` | |
| export class MyEffects { | |
| @Effect() |
| @Injectable() | |
| export class MyEffects { | |
| @Effect() | |
| public myEffect$: Observable<void> = this.action$.pipe( | |
| // ... | |
| // Do something observable-y | |
| // ... | |
| catchError(error => { | |
| // handle error | |
| }) |
| import { tsquery } from '@phenomnomnominal/tsquery'; | |
| import { expect } from 'chai'; | |
| import { ineeda } from 'ineeda'; | |
| import { IOptions, Replacement } from 'tslint'; | |
| import { Rule } from './noFdescribeOrFitRule'; | |
| describe('noFdescribeOrFitRule', () => { | |
| it('should create a lint error if "fdescribe()" is used', () => { | |
| const sourceFile = tsquery.ast(` |
| it('should create a lint fix if "fdescribe()" is used', () => { | |
| const sourceFile = tsquery.ast(` | |
| fdescribe(); | |
| `); | |
| const rule = new Rule({ ruleArguments: [] }); | |
| const errors = rule.apply(sourceFile); | |
| const [error] = errors; |