代码之家  ›  专栏  ›  技术社区  ›  Vinod Louis

通过npm脚本tslint无法正常工作

  •  3
  • Vinod Louis  · 技术社区  · 8 年前

    1. 在命令提示下

      ip-192-168-14-138:scripture-cite vinodlouis$ tslint -c tslint.json src/**/*.ts
      
      ERROR: src/App.ts[1, 23]: ' should be "
      ERROR: src/App.ts[2, 1]: Import sources within a group must be alphabetized.
      ERROR: src/App.ts[2, 26]: ' should be "
      ERROR: src/App.ts[3, 25]: ' should be "
      ERROR: src/App.ts[4, 1]: Import sources within a group must be alphabetized.
      ERROR: src/App.ts[4, 29]: ' should be "
      ERROR: src/App.ts[12, 5]: comment must start with a space
      ERROR: src/App.ts[21, 29]: ' should be "
      ERROR: src/App.ts[31, 9]: Identifier 'router' is never reassigned; use 'const' instead of 'let'.
      ERROR: src/App.ts[33, 16]: ' should be "
      ERROR: src/App.ts[35, 18]: ' should be "
      ERROR: src/App.ts[35, 32]: Missing trailing comma
      ERROR: src/App.ts[38, 22]: ' should be "
      ERROR: src/App.ts[43, 34]: file should end with a newline
      ERROR: src/index.ts[1, 23]: ' should be "
      ERROR: src/index.ts[2, 1]: Import sources within a group must be alphabetized.
      ERROR: src/index.ts[2, 24]: ' should be "
      ERROR: src/index.ts[4, 17]: ' should be "
      ERROR: src/index.ts[6, 7]: ' should be "
      ERROR: src/index.ts[9, 9]: ' should be "
      ERROR: src/index.ts[13, 11]: ' should be "
      ERROR: src/index.ts[14, 11]: ' should be "
      ERROR: src/index.ts[17, 7]: Shadowed name: 'port'
      ERROR: src/index.ts[17, 7]: Identifier 'port' is never reassigned; use 'const' instead of 'let'.
      ERROR: src/index.ts[17, 38]: ' should be "
      ERROR: src/index.ts[18, 3]: if statements must be braced
      ERROR: src/index.ts[19, 8]: if statements must be braced
      ERROR: src/index.ts[20, 3]: else statements must be braced
      ERROR: src/index.ts[24, 3]: if statements must be braced
      ERROR: src/index.ts[24, 25]: ' should be "
      ERROR: src/index.ts[25, 7]: Identifier 'bind' is never reassigned; use 'const' instead of 'let'.
      ERROR: src/index.ts[25, 31]: ' should be "
      ERROR: src/index.ts[25, 43]: ' should be "
      ERROR: src/index.ts[25, 60]: ' should be "
      ERROR: src/index.ts[26, 9]: missing whitespace
      ERROR: src/index.ts[27, 10]: ' should be "
      ERROR: src/index.ts[28, 7]: Calls to 'console.error' are not allowed.
      ERROR: src/index.ts[31, 10]: ' should be "
      ERROR: src/index.ts[32, 7]: Calls to 'console.error' are not allowed.
      ERROR: src/index.ts[41, 7]: Identifier 'addr' is never reassigned; use 'const' instead of 'let'.
      ERROR: src/index.ts[42, 7]: Identifier 'bind' is never reassigned; use 'const' instead of 'let'.
      ERROR: src/index.ts[42, 31]: ' should be "
      ERROR: src/index.ts[44, 2]: file should end with a newline
      
    2. 通过npm脚本

      ip-192-168-14-138:scripture-cite vinodlouis$ npm run lint
      
      > scripture-cite@1.0.0 lint /Users/vinodlouis/projects/rb/scripture-cite
      > tslint -c tslint.json src/**/*.ts
      
      The 'comment-format' rule threw an error in 'src/App.ts':
      TypeError: ts.forEachLeadingCommentRange is not a function
          at /Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:403:16
          at iterate (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:366:20)
          at Array.forEach (<anonymous>)
          at iterate (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:368:50)
          at Array.forEach (<anonymous>)
          at iterate (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:368:50)
          at Array.forEach (<anonymous>)
          at iterate (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:368:50)
          at forEachToken (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:369:7)
          at Object.forEachComment (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:399:12)
      The 'jsdoc-format' rule threw an error in 'src/App.ts':
      TypeError: ts.forEachLeadingCommentRange is not a function
          at /Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:403:16
          at iterate (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:366:20)
          at Array.forEach (<anonymous>)
          at iterate (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:368:50)
          at Array.forEach (<anonymous>)
          at iterate (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:368:50)
          at Array.forEach (<anonymous>)
          at iterate (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:368:50)
          at forEachToken (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:369:7)
          at Object.forEachComment (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:399:12)
      TypeError: ts.forEachLeadingCommentRange is not a function
          at /Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:403:16
          at iterate (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:366:20)
          at Array.forEach (<anonymous>)
          at iterate (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:368:50)
          at Array.forEach (<anonymous>)
          at iterate (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:368:50)
          at Array.forEach (<anonymous>)
          at iterate (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:368:50)
          at forEachToken (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:369:7)
          at Object.forEachComment (/Users/vinodlouis/projects/rb/scripture-cite/node_modules/tsutils/util/util.js:399:12)
      npm ERR! code ELIFECYCLE
      npm ERR! errno 1
      npm ERR! scripture-cite@1.0.0 lint: `tslint -c tslint.json src/**/*.ts`
      npm ERR! Exit status 1
      npm ERR! 
      npm ERR! Failed at the scripture-cite@1.0.0 lint script.
      npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
      
      npm ERR! A complete log of this run can be found in:
      npm ERR!     /Users/vinodlouis/.npm/_logs/2018-07-19T06_16_52_537Z-debug.log
      

    package.json

    {
      "name": "scripture-cite",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "build": "gulp scripts",
        "start": "node dist/index.js",
        "test": "mocha --reporter spec --compilers ts:ts-node/register 'test/**/*.test.ts'",
        "lint": "tslint -c tslint.json src/**/*.ts"
      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "@types/body-parser": "0.0.33",
        "@types/chai": "^3.4.34",
        "@types/chai-http": "^0.0.29",
        "@types/debug": "0.0.29",
        "@types/express": "^4.0.37",
        "@types/express-serve-static-core": "4.0.49",
        "@types/mocha": "^2.2.32",
        "@types/morgan": "^1.7.32",
        "@types/node": "^6.0.46",
        "chai": "^3.5.0",
        "chai-http": "^3.0.0",
        "gulp": "^3.9.1",
        "gulp-tslint": "^8.1.3",
        "gulp-typescript": "^3.1.1",
        "lint": "^1.1.2",
        "mocha": "^3.1.2",
        "ts-node": "^7.0.0",
        "tslint": "^5.11.0",
        "typescript": "^2.0.6"
      },
      "dependencies": {
        "body-parser": "^1.15.2",
        "debug": "^2.2.0",
        "express": "^4.14.0",
        "morgan": "^1.7.0"
      }
    }
    

    tsconfig.json

    {
        "compilerOptions": {
          "target": "es6",
          "module": "commonjs",
          "outDir": "dist"
        },
        "include": [
          "src/**/*.ts"
        ],
        "exclude": [
          "node_modules"
        ]
      }
    

    tslint.json

    {
        "defaultSeverity": "error",
        "extends": [
            "tslint:recommended"
        ],
        "linterOptions": {
            "exclude": [
                "node_modules"
            ]
        },
        "jsRules": {},
        "rules": {},
        "rulesDirectory": []
    }
    
    0 回复  |  直到 8 年前