$ $(yarn bin)/tslint --version
5.7.0
$ $(yarn bin)/tsc --version
Version 2.5.2
أنا أقوم بتشغيل 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
لأن المستخدمين (بمن فيهم أنا) يستفيدون من ميزة الإصلاح التلقائي.
ومع ذلك ، يشير التحذير إلى أنه لا ينبغي أن أستخدم القاعدة على الإطلاق ، ويسبب الكثير من المخرجات غير الضرورية لوحدة التحكم ، مما قد يحجب معلومات مهمة أخرى مثل المشاكل غير القابلة للإصلاح في الكود.
أعتقد أنه سيكون من الجيد إزالة التحذير.
بالنسبة لي ، فإن المتغير "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؟ تبدو هذه مشكلة منفصلة عن المنشور الأصلي ؛ أود أن أشجعك على فتح مشكلة أخرى إذا لم تكن قد قمت بذلك بالفعل.
التعليق الأكثر فائدة
destroyerofbuilds تبدو وكأنها نقطة جيدة - فأنت تستخدم
no-unused-variable
أساسي لوظيفة الإصلاح التلقائي ، لذا فإن التحذير غير ذي صلة. أعتقد أنه يجب علينا إزالة التحذير (قبول العلاقات العامة). سيكون من الجيد أيضًا تحديث مستندات القاعدة لوصف نمط الاستخدام هذا.