2016-12-02 88 views
13

我升級我的tslint到4.0.2,現在我得到了很多的錯誤,如以下更新TSLint錯誤:未能找到在

Could not find implementations for the following rules specified in the configuration: 
    directive-selector-name 
    component-selector-name 
    directive-selector-type 
    component-selector-type 
    directive-selector-prefix 
    component-selector-prefix 
    label-undefined 
    no-constructor-vars 
    no-duplicate-key 
    no-unreachable 
    use-strict 

配置中指定的以下規則我認爲問題可能實現因爲我的tslint.json可能已過時,我需要更新它,但我還沒有找到任何有關如何做的信息,或者即使我的假設是正確的。

tslint.json

{ 
    "rulesDirectory": [ 
    "node_modules/codelyzer" 
    ], 
    "rules": { 
    "directive-selector-name": [true, "camelCase"], 
    "component-selector-name": [true, "kebab-case"], 
    "directive-selector-type": [true, "attribute"], 
    "component-selector-type": [true, "element"], 
    "directive-selector-prefix": [true, "my"], 
    "component-selector-prefix": [true, "my"], 
    "use-input-property-decorator": true, 
    "use-output-property-decorator": true, 
    "use-host-property-decorator": true, 
    "no-attribute-parameter-decorator": true, 
    "no-input-rename": true, 
    "no-output-rename": true, 
    "no-forward-ref" :true, 
    "use-life-cycle-interface": true, 
    "use-pipe-transform-interface": true, 
    "pipe-naming": [true, "camelCase", "my"], 
    "component-class-suffix": true, 
    "directive-class-suffix": true, 
    "ban": [true, 
     ["_", "extend"], 
     ["_", "isNull"], 
     ["_", "isDefined"] 
    ], 
    "class-name": true, 
    "comment-format": [false, 
     "check-space", 
     "check-lowercase" 
    ], 
    "curly": true, 
    "eofline": true, 
    "forin": true, 
    "indent": [true, 2], 
    "interface-name": true, 
    "jsdoc-format": true, 
    "label-position": true, 
    "label-undefined": true, 
    "max-line-length": [false, 140], 
    "member-ordering": [true, 
     "public-before-private", 
     "static-before-instance", 
     "variables-before-functions" 
    ], 
    "no-arg": true, 
    "no-bitwise": true, 
    "no-console": [true, 
     "debug", 
     "info", 
     "time", 
     "timeEnd", 
     "trace" 
    ], 
    "no-construct": true, 
    "no-constructor-vars": false, 
    "no-debugger": true, 
    "no-duplicate-key": true, 
    "no-duplicate-variable": true, 
    "no-empty": true, 
    "no-eval": true, 
    "no-string-literal": true, 
    "no-switch-case-fall-through": true, 
    "trailing-comma": true, 
    "no-trailing-whitespace": true, 
    "no-unused-expression": true, 
    "no-unused-variable": true, 
    "no-unreachable": true, 
    "no-use-before-declare": true, 
    "no-var-requires": true, 
    "one-line": [true, 
     "check-open-brace", 
     "check-catch", 
     "check-else", 
     "check-whitespace" 
    ], 
    "quotemark": [true, "single"], 
    "radix": true, 
    "semicolon": true, 
    "triple-equals": [true, "allow-null-check"], 
    "typedef": [true, 
     "callSignature", 
     "indexSignature", 
     "parameter", 
     "propertySignature", 
     "variableDeclarator" 
    ], 
    "typedef-whitespace": [true, 
     ["callSignature", "noSpace"], 
     ["catchClause", "noSpace"], 
     ["indexSignature", "space"] 
    ], 
    "use-strict": false, 
    "variable-name": false, 
    "whitespace": [true, 
     "check-branch", 
     "check-decl", 
     "check-operator", 
     "check-separator", 
     "check-type" 
    ] 
    } 
} 

packages.json

{ 
    "dependencies": { 
    "@angular/common": "^2.2.4", 
    "@angular/compiler": "^2.2.4", 
    "@angular/core": "^2.2.4", 
    "@angular/forms": "^2.2.4", 
    "@angular/http": "^2.2.4", 
    "@angular/platform-browser": "^2.2.4", 
    "@angular/platform-browser-dynamic": "^2.2.4", 
    "@angular/router": "^3.2.4", 
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.14", 
    "ag-grid": "^7.0.0", 
    "angularfire2": "^2.0.0-beta.5", 
    "core-js": "^2.4.1", 
    "firebase": "^3.6.2", 
    "rxjs": "5.0.0-rc.4", 
    "zone.js": "^0.7.2" 
    }, 
    "devDependencies": { 
    "del": "^2.0.2", 
    "gulp": "gulpjs/gulp#4ed9a4a3275559c73a396eff7e1fde3824951ebb", 
    "gulp-hub": "frankwallis/gulp-hub#d461b9c700df9010d0a8694e4af1fb96d9f38bf4", 
    "gulp-filter": "^4.0.0", 
    "gulp-util": "^3.0.7", 
    "gulp-sass": "^2.1.1", 
    "browser-sync": "^2.18.2", 
    "browser-sync-spa": "^1.0.3", 
    "karma": "^1.3.0", 
    "karma-coverage": "^1.1.1", 
    "karma-jasmine": "^1.0.2", 
    "karma-junit-reporter": "^1.1.0", 
    "jasmine": "^2.4.1", 
    "es6-shim": "^0.35.0", 
    "karma-chrome-launcher": "^2.0.0", 
    "babel-plugin-istanbul": "^3.0.0", 
    "karma-webpack": "^1.7.0", 
    "webpack": "2.1.0-beta.20", 
    "html-webpack-plugin": "^2.24.1", 
    "style-loader": "^0.13.0", 
    "css-loader": "^0.26.0", 
    "postcss-loader": "^1.1.1", 
    "autoprefixer": "^6.5.3", 
    "json-loader": "^0.5.4", 
    "extract-text-webpack-plugin": "^2.0.0-beta.3", 
    "html-loader": "^0.4.3", 
    "ts-loader": "^1.2.2", 
    "sass-loader": "^4.0.2", 
    "node-sass": "^3.13.0", 
    "eslint": "^3.11.1", 
    "eslint-config-xo-space": "^0.15.0", 
    "eslint-loader": "^1.6.1", 
    "babel-loader": "^6.2.8", 
    "babel-eslint": "^7.1.1", 
    "eslint-plugin-babel": "^4.0.0", 
    "tslint": "^4.0.2", 
    "typescript": "^2.0.10", 
    "typings": "^2.0.0", 
    "tslint-loader": "^3.2.1", 
    "codelyzer": "^2.0.0-beta.1" 
    }, 
    "scripts": { 
    "build": "gulp", 
    "serve": "gulp serve", 
    "serve:dist": "gulp serve:dist", 
    "test": "gulp test", 
    "test:auto": "gulp test:auto" 
    }, 
    "eslintConfig": { 
    "root": true, 
    "env": { 
     "browser": true, 
     "jasmine": true 
    }, 
    "extends": [ 
     "xo-space/esnext" 
    ] 
    } 
} 

回答

33

我在同一條船上。我不知道你以前的tslint版本是什麼,但是對於我來說,我已經從3.15.1升級到4.0.2,並且由此產生的「破壞規則」列表與您的不同。儘管如此,我還是可以爲你和我共同的人提供一些修正/解釋。

我剛去了tslint's changelog on GitHub,發現破的規則,得到了行尾的問題號,&查找了這個問題。最簡單的導航方式是將問題編號添加到他們的GitHub問題URL的末尾。例如,label-undefined爲HTTP // github.com /真知晶球/ tslint /問題/ 877

這裏是那些我必須弄清楚

  • 標籤未定義 - >打字稿編譯器現在處理這個問題,所以從tslint.json刪除"label-undefined": true,然後添加"allowUnusedLabels": false您tsconfig.json的compilerOptions部分
  • 無構造 - 瓦爾 - >改名規則,所以在您的tslint.json改變"no-constructor-vars""no-parameter-properties"
  • no-duplicate-key - >刪除"no-duplicate-key": true現在可以處理它(如果是dup鍵,將不會編譯)。
  • 無可達 - >打字稿編譯器處理現在這個樣子,所以從tslint.json刪除"no-unreachable": true,然後添加"noImplicitReturns": true您tsconfig.json的compilerOptions部分
  • 使用嚴格 - >完全刪除"use-strict"規則b/c typescript現在以嚴格模式解析所有模塊主體。
+0

還是有用的解決方案,很好的解釋! –

2

tslint V4取出一堆不再有意義和打字稿檢查得到更好的規則。如果您仍想使用這些規則,則需要使用tslint v3。

+0

感謝您的幫助Basarat –

4

從codelyzer 2.0.0-beta.1開始,有一些重大改變。 他們刪除了不再支持的指令選擇器名稱,組件選擇器名稱,指令選擇器類型,組件選擇器類型,指令選擇器前綴和組件選擇器前綴。相反,他們增加了如下規則:

"directive-selector": [true, "attribute", "app", "camelCase"], 
"component-selector": [true, "element", "app", "kebab-case"], 

請看changelog爲codelyzer和搜索不支持

0

我有同樣的問題與Could not find implementations for the following rules...警告顯示在我的IDE的任何規則, WebStorm 2016.x.就我而言,該規則的實施是由IDE提供的,因爲我的升級固定WebStorm的問題。

我升級打字稿,TSLint & Codelyzer無濟於事。我檢查我的tslint.json文件的內容,並沒有發現什麼。升級WebStorm解決了這個問題。

0

從我的角度項目複製的規則後有同樣的問題。 只需創建一個新的空打字稿的項目,你會被罰款。