Shakeer Hussain
Shakeer Hussain

Reputation: 2536

double quotes should be single quote error in Angular

How to resolve prod build error?

ERROR: /home/vsts/work/1/s/src/app/app.component.spec.ts[1, 32]: " should be ' ERROR: /home/vsts/work/1/s/src/app/app.component.spec.ts[2, 30]: " should be ' All files pass linting. Lint warnings found in the listed files. Lint errors found in the listed files. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] ng: ng "lint" npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] ng script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I tried the below commands to reproduce the error, but it can't be reproduced in my machine. How can I fix this error?

npm run ng build --prod
npm run ng build --env=prod
npm run build:prod

Error not showing after adding quotemak:false, I have more errors. 1) comment must start with a space 2) object access via string literals is disallowed 3) Assignments in conditional expressions are forbidden etc.

How i can ignore all lint errors? Do i have explicitly mention for each error?

Upvotes: 1

Views: 7265

Answers (2)

wentjun
wentjun

Reputation: 42556

It is just a TSLint warning, and as you might have known, TSLint is by default installed in Angular. You should just replace all double quotes(") with single quotes('), or you turn off the quotemark rule on your tslint.json

"rules": {
  "quotemark": [ false ]
}

Upvotes: 10

Prabh
Prabh

Reputation: 1069

Edit package.json and add a new script entry

"scripts": {
    ...
    "lint": "ng lint",
    "lint-fix": "ng lint --fix",
    ...
  },

And then run lint-fix script to fix all auto-fixable warnings raised.

npm lint-fix

Upvotes: 1

Related Questions