Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

313
Views
¿Existe una regla eslint para detectar propiedades de clase no utilizadas?

Estoy trabajando con un proyecto Angular y mi configuración de ESLint no detecta cuando una variable de clase privada no se usa, por ejemplo

 @Component{...} export class ExampleComponent { private exampleProperty: string }

La propiedad privada anterior - exampleProperty no se resaltará con la configuración actual de ESLint que tengo.

Mi .eslintrc.json :

 { "root": true, "ignorePatterns": ["projects/**/*"], "overrides": [ { "files": ["*.ts"], "parserOptions": { "project": ["tsconfig.json", "e2e/tsconfig.json"], "createDefaultProgram": true }, "env": { "browser": true, "jest": true }, "extends": [ "eslint:recommended", "plugin:@angular-eslint/recommended", "plugin:@angular-eslint/template/process-inline-templates", "plugin:@typescript-eslint/recommended" ], "rules": { "@angular-eslint/component-selector": [ "error", { "prefix": "app", "style": "kebab-case", "type": "element" } ], "@angular-eslint/no-host-metadata-property": "off", "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/ban-types": "off", "@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-unused-vars": [ "error", { "argsIgnorePattern": "^_" } ], "no-case-declarations": "off", "no-console": ["error", { "allow": ["warn", "error"] }], "no-prototype-builtins": "off", "no-unused-vars": "off" } }, { "files": ["*.html"], "extends": ["plugin:@angular-eslint/template/recommended"], "rules": {} } ] }

¿Cómo puedo hacer que el linter recoja esto?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede hacer que TypeScript recoja esto por usted activando la opción noUnusedLocals en tsconfig.json . ("Locales" aparentemente incluye propiedades privadas no utilizadas, que después de todo son locales para la clase).

Aquí hay un parque infantil con esa clase con la opción activada, lo que da el error:

Se declara 'exampleProperty' pero su valor nunca se lee.(6133)

(Agregué un constructor y configuré la propiedad, solo para que el error no se mezcle / oculte por el error de que no se inicializó).

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!