'Location' is already defined as a built-in global variable from eslint in Angular 18 project

Discussão em 'Angular' iniciado por AsGoodAsItGets, Outubro 31, 2024.

  1. I'm migrating an Angular 17 project to Angular 18 and in the process I'm also migrating eslint, prettier, and assorted configurations to the latest. After fixing a lot of issues related to the new flat config, now I'm getting this eslint error:

    1:10 error 'Location' is already defined as a built-in global variable @typescript-eslint/no-redeclare


    on a line like this:

    import { Location } from '@angular/common';


    My rules were automatically migrated from the old eslint config format to the new and they look like this:

    ...
    .extends(
    'eslint:recommended',
    'plugin:mad:typescript-eslint/recommended',
    'plugin:mad:angular-eslint/recommended',
    'plugin:mad:angular-eslint/template/process-inline-templates',
    'plugin:prettier/recommended',
    'plugin:mad:ngrx/all'
    )
    ...
    rules: {
    ...
    'no-redeclare': 'off',
    '@typescript-eslint/no-redeclare': 'error',
    ...
    }


    Relevant versions in package.json are:

    "@angular-eslint/builder": "18.4.0",
    "@angular-eslint/eslint-plugin": "18.4.0",
    "@angular-eslint/eslint-plugin-template": "18.4.0",
    "@angular-eslint/schematics": "18.4.0",
    "@angular-eslint/template-parser": "18.4.0",
    "eslint": "9.13.0",
    "@typescript-eslint/eslint-plugin": "8.12.2",
    "@typescript-eslint/parser": "8.12.2",


    I understand that Location is a global variable (in a browser context), but the Location service from Angular is a different object, so why is typescript-eslint complaining about it?

    Continue reading...

Compartilhe esta Página