Skip to content
Merged

Eslint #1020

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
ignores: ['dist/**', 'lib/**', 'node_modules/**', '_doc/**', '_bundles/**'],
},
{
files: ['src/**/*.ts'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files: ['test/**/*.ts'],
languageOptions: {
parserOptions: {
project: './test/tsconfig.spec.json',
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files: ['**/*.ts'],
rules: {
// Rules migrated from tslint.json
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'no-eval': 'error',
'no-debugger': 'error',
'prefer-const': 'error',
'no-var': 'error',
eqeqeq: ['error', 'smart'],
radix: 'error',

// Relaxed rules to match tslint config
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'no-empty': 'off',
},
}
);
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"test:zoneless:watch": "vitest watch --project zoneless",
"docs": "generate_docs",
"docs:publish": "generate_docs && publish_docs",
"lint": "eslint src test",
"prepublishOnly": "echo && echo DO NOT RUN npm publish. Instead, run npm run release && echo && echo && false",
"changelog": "update_changelog --include-core",
"prepare": "husky"
Expand Down Expand Up @@ -74,7 +75,9 @@
"pretty-quick": "^4.0.0",
"rxjs": "~7.8.2",
"tslib": "^2.8.1",
"tslint": "^6.1.0",
"@eslint/js": "^9.28.0",
"eslint": "^9.28.0",
"typescript-eslint": "^8.33.0",
"typescript": "~5.9.3",
"vitest": "^4.0.8",
"zone.js": "~0.16.0"
Expand Down
2 changes: 1 addition & 1 deletion src/directives/uiSref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class UISref implements OnChanges {
this.update();
}

ngOnChanges(changes: SimpleChanges): void {
ngOnChanges(_changes: SimpleChanges): void {
this.update();
}

Expand Down
4 changes: 2 additions & 2 deletions src/directives/uiSrefStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@uirouter/core';

import { Subscription, Observable, BehaviorSubject, of, from, combineLatest, concat } from 'rxjs';
import { switchMap, map, tap } from 'rxjs/operators';
import { switchMap, map } from 'rxjs/operators';

/** @internal */
interface TransEvt {
Expand Down Expand Up @@ -66,7 +66,7 @@ const pathMatches = (target: TargetState): Predicate<PathNode[]> => {
const paramSchema: Param[] = targetPath
.map((node) => node.paramSchema)
.reduce(unnestR, [])
.filter((param: Param) => targetParamVals.hasOwnProperty(param.id));
.filter((param: Param) => Object.prototype.hasOwnProperty.call(targetParamVals, param.id));

return (path: PathNode[]) => {
const tailNode = tail(path);
Expand Down
8 changes: 5 additions & 3 deletions src/directives/uiView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@ export class UIView implements OnInit, OnDestroy {
/** The reference to the component currently inside the viewport */
readonly _componentRef = signal<ComponentRef<any> | null>(null);
/** Deregisters the ui-view from the view service */
private _deregisterUIView: Function;
/** Deregisters the master uiCanExit transition hook */
private _deregisterUIView: () => void;
/** Deregisters the master uiCanExit transition hook (returns Function from @uirouter/core) */
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
private _deregisterUiCanExitHook: Function;
/** Deregisters the master uiOnParamsChanged transition hook */
/** Deregisters the master uiOnParamsChanged transition hook (returns Function from @uirouter/core) */
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
private _deregisterUiOnParamsChangedHook: Function;
/** Data about the this UIView */
private _uiViewData: ActiveUIView = <any>{};
Expand Down
2 changes: 1 addition & 1 deletion src/lazyLoad/lazyLoadNgModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export function applyComponent<T>(
const current = stateObject.component;
stateObject.component = component || current;
const removed = registry.deregister(stateObject).map((child) => child.self);
const children = removed.filter((i) => i.name != stateObject.name);
const children = removed.filter((i) => i.name !== stateObject.name);

return { states: [stateObject, ...children] };
}
2 changes: 1 addition & 1 deletion src/location/locationConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class Ng2LocationConfig extends BrowserLocationConfig {
super(router, is(PathLocationStrategy)(_locationStrategy));
}

baseHref(href?: string): string {
baseHref(_href?: string): string {
return this._locationStrategy.getBaseHref();
}
}
3 changes: 1 addition & 2 deletions src/statebuilders/lazyLoad.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LazyLoadResult, Transition, StateDeclaration } from '@uirouter/core'; // has or is using
import { BuilderFunction, StateObject } from '@uirouter/core';
import { loadComponent, loadNgModule } from '../lazyLoad/lazyLoadNgModule';

Expand Down Expand Up @@ -45,7 +44,7 @@ import { loadComponent, loadNgModule } from '../lazyLoad/lazyLoadNgModule';
* ```
*
*/
export function ng2LazyLoadBuilder(state: StateObject, parent: BuilderFunction) {
export function ng2LazyLoadBuilder(state: StateObject, _parent: BuilderFunction) {
const loadComponentFn = state['loadComponent'];
const loadNgModuleFn = state['loadChildren'];
return loadComponentFn
Expand Down
6 changes: 3 additions & 3 deletions src/uiRouterConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function applyModuleConfig(uiRouter: UIRouter, injector: Injector, module
}

export function applyRootModuleConfig(uiRouter: UIRouter, injector: Injector, module: RootModule) {
isDefined(module.deferIntercept) && uiRouter.urlService.deferIntercept(module.deferIntercept);
isDefined(module.otherwise) && uiRouter.urlService.rules.otherwise(module.otherwise);
isDefined(module.initial) && uiRouter.urlService.rules.initial(module.initial);
if (isDefined(module.deferIntercept)) uiRouter.urlService.deferIntercept(module.deferIntercept);
if (isDefined(module.otherwise)) uiRouter.urlService.rules.otherwise(module.otherwise);
if (isDefined(module.initial)) uiRouter.urlService.rules.initial(module.initial);
}
2 changes: 1 addition & 1 deletion test/uiSrefActive/uiSrefActive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('uiSrefActive', () => {
await router.stateService.go('statea');
await tick();
fixture.detectChanges();
let classList = des[0].nativeElement.classList;
const classList = des[0].nativeElement.classList;
expect(classList).toContain(activeClasses[0]);
expect(classList).toContain(activeClasses[1]);
});
Expand Down
2 changes: 1 addition & 1 deletion test/uiSrefStatus/uiSrefStatus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('uiSrefStatus', () => {
standalone: false,
})
class TestComponent {
updated(event: SrefStatus) {
updated(_event: SrefStatus) {
throw new Error('updated() method must be spied');
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/uiView/resolveBinding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ describe('uiView', () => {
describe('should map resolve data to inputs', () => {
@Component({ template: `<h3>hey</h3> `, standalone: false })
class ManyResolvesComponent {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
constructor(@Inject('resolve1') foo, @Inject('Resolve2') bar, @Inject('resolve5') baz) {
// eslint-disable-next-line prefer-rest-params
this.injectedValues = Array.from(arguments);
}

Expand Down
2 changes: 1 addition & 1 deletion test/uiView/uiOnParamsChanged.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('uiView', () => {
class ParamWatcherComponent implements OnInit {
$id = id++;

public uiOnParamsChanged(newParams: { [paramName: string]: any }, trans: Transition) {
public uiOnParamsChanged(newParams: { [paramName: string]: any }, _trans: Transition) {
paramChanges.push(newParams);
}

Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
Expand All @@ -19,5 +20,5 @@
"skipTemplateCodegen": true,
"strictMetadataEmit": true
},
"files": ["src/index.ts"]
"include": ["src/**/*.ts"]
}
46 changes: 0 additions & 46 deletions tslint.json

This file was deleted.

Loading