Tslint: تم عرض تحذير لقاعدة "no-unused-variable" المدعومة

تم إنشاؤها على ١٣ سبتمبر ٢٠١٧  ·  3تعليقات  ·  مصدر: palantir/tslint

تقرير الشوائب

  • __TSLint الإصدار__:
$ $(yarn bin)/tslint --version
5.7.0
  • __TypeScript إصدار__:
$ $(yarn bin)/tsc --version
Version 2.5.2
  • __ تشغيل TSLint عبر__: CLI

السلوك الفعلي

أنا أقوم بتشغيل tslint عبر قاعدة رمز موجودة.

يحتوي مشروعي على مجموعة القواعد no-unused-variable (من خلال استخدام حزمة شبيهة مسبقًا).

يحتوي مشروعي أيضًا على خيارات المترجم noUnusedLocals و noUnusedParameters ممكّنة لـ TypeScript (مقابل ، من خلال استخدام حزمة شبيهة مسبقًا).

أقوم أحيانًا بتحديث القواعد الخاصة بي وتشغيل الخيار tslint 's --fix لإصلاح الكود تلقائيًا.

يتضمن ذلك الاستفادة من ميزة الإصلاح التلقائي لقاعدة no-unused-variable .

مثال على الإخراج عند تشغيل tslint --fix على قاعدة الشفرة الخاصة بي:

$ $(yarn bin)/tslint --project tsconfig.json --config tslint.json --fix src/**/*.ts
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.
WARNING: 'no-unused-variable' lint rule does not need to be set if the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.

سلوك متوقع

كما هو مذكور هنا ، لم يتم إهمال قاعدة no-unused-variable لأن المستخدمين (بمن فيهم أنا) يستفيدون من ميزة الإصلاح التلقائي.

ومع ذلك ، يشير التحذير إلى أنه لا ينبغي أن أستخدم القاعدة على الإطلاق ، ويسبب الكثير من المخرجات غير الضرورية لوحدة التحكم ، مما قد يحجب معلومات مهمة أخرى مثل المشاكل غير القابلة للإصلاح في الكود.

أعتقد أنه سيكون من الجيد إزالة التحذير.

P3 Accepting PRs Bug

التعليق الأكثر فائدة

destroyerofbuilds تبدو وكأنها نقطة جيدة - فأنت تستخدم no-unused-variable أساسي لوظيفة الإصلاح التلقائي ، لذا فإن التحذير غير ذي صلة. أعتقد أنه يجب علينا إزالة التحذير (قبول العلاقات العامة). سيكون من الجيد أيضًا تحديث مستندات القاعدة لوصف نمط الاستخدام هذا.

ال 3 كومينتر

بالنسبة لي ، فإن المتغير "no-unused-variable" لا يفعل شيئًا ؛ (
الإصدار 5.7.0

هذا هو التكوين الخاص بي

{
    "extends": [
        "tslint:latest",
        "tslint-react",
        "tslint-config-prettier"
    ],
    "rules": {
        "ban-types": false,
        "interface-name": null,
        "interface-over-type-literal": false,
        "jsx-boolean-value": null,
        "jsx-no-lambda": null,
        "max-classes-per-file": [],
        "member-access": false,
        "no-namespace": null,
        "no-unused-expression": [false],
        "no-unused-variable": true,
        "no-var-requires": false,
        "object-literal-shorthand": false,
        "object-literal-sort-keys": false,
        "only-arrow-functions": null,
        "ordered-imports": null,
        "prefer-const": false,
        "variable-name": false,
        "no-invalid-template-strings": false,
        "no-submodule-imports": false
    }
}

destroyerofbuilds تبدو وكأنها نقطة جيدة - فأنت تستخدم no-unused-variable أساسي لوظيفة الإصلاح التلقائي ، لذا فإن التحذير غير ذي صلة. أعتقد أنه يجب علينا إزالة التحذير (قبول العلاقات العامة). سيكون من الجيد أيضًا تحديث مستندات القاعدة لوصف نمط الاستخدام هذا.

tomitrescak كيف تدير TSLint؟ تبدو هذه مشكلة منفصلة عن المنشور الأصلي ؛ أود أن أشجعك على فتح مشكلة أخرى إذا لم تكن قد قمت بذلك بالفعل.

هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات