it-source

npm 스크립트에서 eslint --fix를 실행하는 방법

criticalcode 2023. 10. 8. 09:56
반응형

npm 스크립트에서 eslint --fix를 실행하는 방법

패키지에 보풀 수정을 추가하려고 합니다.json.저의 기본 보풀은"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"

해봤어요."lint-fix": "eslint --fix --ext .js,.vue src test/unit/specs test/e2e/specs"그러나 그것은 나의 실수를 던져주는 것이지 그것을 고치지는 않습니다.

무엇을 바꾸어야 합니까?

NPM의 오류는 다음과 같습니다.

217 problems (217 errors, 0 warnings)
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run-script" "lint-fix"
npm ERR! node v5.10.1
npm ERR! npm v3.8.3
npm ERR! code ELIFECYCLE
npm ERR! quasar-app@0.0.1 lint-fix: eslint --fix --ext .js,.vue src
npm ERR! Exit status 1
npm ERR! but it is caused by exit code 1 which is result of finding errors.

아래 명령을 실행할 수 있습니다.

npm run lint -- --fix

package.json에서 새 명령어를 추가할 수 있습니다.

"scripts": {
    "lint": "eslint --fix --ext .js,.jsx ."
}

그리고 나서 터미널에서 실행할 수 있습니다.npm run lint.

확장명이 있는 파일의 보풀 문제를 자동으로 수정하기 위해 별도의 새 스크립트를 추가하려면 다음과 같이 하십시오..js그리고..jsx, 당신은 당신의 안에 스크립트를 추가할 수 있습니다.package.json아래와 같이

"lint:fix": "eslint --fix --ext .js,.jsx ."

그래서 위 명령어를 추가한 후에 당신의 스크립트 섹션.package.json다음과 같이 나타낼 수 있습니다.

...
....
"scripts": {
  "start": "react-scripts start",
  "build": "react-scripts build",
  "test": "react-scripts test",
  "eject": "react-scripts eject",
  "lint": "eslint .",
  "lint:fix": "eslint --fix --ext .js,.jsx ."
},
....
...

새로 추가된 스크립트를 실행하여 명령줄의 린팅 문제를 자동으로 수정하려면 다음과 같이 명령을 실행해야 합니다.

npm run lint:fix

해라

./node_modules/.bin/eslint --fix .

eslint auto-rect-correct 명령을 입력합니다.모든 문제를 해결해 줍니다.

먼저 오류를 확인하려면:

npx eslint .

모든 파일의 문제를 해결하려면(자동 수정 옵션)

npx eslint --fix .

이것이 제가 사용하는 것입니다.

npx eslint --fix . 

모든 파일을 수정합니다.

언급URL : https://stackoverflow.com/questions/40271230/how-to-run-eslint-fix-from-npm-script

반응형