codememo

--eslint를 사용해도 오류는 수정되지 않습니다.

tipmemo 2023. 2. 22. 21:55
반응형

--eslint를 사용해도 오류는 수정되지 않습니다.

비주얼 코드에서 eslint를 사용하여 js 파일을 포맷하고 있지만 실행할 때마다 오류가 발생합니다.이것이 실행 명령어 라인입니다.node ./node_modules/eslint/bin/eslint -- src --fix에러 메시지

E:\PATH\src\reducers\roote-reducer.js
  1:8   error  There should be no space after '{'                object-curly-spacing
  1:26  error  There should be no space before '}'               object-curly-spacing
  6:1   error  Expected indentation of 1 tab but found 2 spaces  indent
  7:1   error  Expected indentation of 1 tab but found 2 spaces  indent
  8:4   error  Newline required at end of file but not found     eol-last

E:\PATH\src\reducers\schedule-reducer.js
   1:8   error  There should be no space after '{'                  object-curly-spacing
   1:22  error  There should be no space before '}'                 object-curly-spacing
   4:1   error  Expected indentation of 1 tab but found 4 spaces    indent
   7:24  error  Missing space before function parentheses           space-before-function-paren
   7:54  error  Missing space before opening brace                  space-before-blocks
   8:1   error  Expected indentation of 1 tab but found 4 spaces    indent
   9:1   error  Expected indentation of 1 tab but found 4 spaces    indent

E:\PATH\src\register-service-worker.js
   12:1  error  Expected indentation of 1 tab but found 2 spaces    indent
   17:1  error  Expected indentation of 5 tabs but found 6 spaces   indent
   17:7  error  Use regex shorthands to improve readability         unicorn/regex-shorthand
   22:1  error  Expected indentation of 1 tab but found 2 spaces    indent

✖ 309 problems (309 errors, 0 warnings)
  309 errors, 0 warnings potentially fixable with the `--fix` option.

어떻게 하면 자동으로 고칠 수 있나요?

사용방법--fixeslint를 직접 실행해야 합니다.

이거 드셔보세요

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

Windows 의 경우:

.\node_modules\.bin\eslint src\** --fix

형식은 다음과 같습니다.

./node_modules/.bin/eslint --fix path/to/file.js

자세한 배경은 이 스레드(aravind1078의 답변)를 참조하십시오.

새 단말기에서 다음 명령을 실행합니다.

./node_modules/.bin/eslint --fix . --ext .js,.vue src

도망가려고 하다

eslint --fix

먼저 eslint를 설치해야 합니다.

npm install -g eslint

다음 명령을 수행합니다.에서 다음을 수행합니다.

eslint --fix .

대신

eslint --fix 

명령어에는 코드가 존재하는 디렉토리 또는 보풀을 적용할 파일 자체를 나타내는 인수가 필요합니다.

명령줄 터미널을 사용하여 Visual Studio Code에서 다음 명령을 실행합니다.

작업 중인 프로젝트에 대해 .eslintrc.yml 파일이 구성되어 있는지 확인합니다.

파일의 보풀 문제를 해결하려면

npx eslint file1.js --fix

폴더의 모든 파일에서 보풀 문제를 해결하려면

npx eslint ./folder_name --fix
  • 사용하는 데 어려움이 있었습니다.--fixNuxt.js 프로젝트에서 @nuxtjs/eslint-module이 아닌 eslint-config-airbnb-base를 사용하는 경우
  • 그 당시 eslint dircly는 나에게 효과가 있었다../node_modules/.bin/eslint --fix


, 2개의 스크립트를 패키지에 더 쓰는 것이 좋습니다.json

"syslog": "eslint --ext \.xt,.vue\" --syslog-path.syslog.ignore." ,"pm-fix" : "npm run lint ----fix"

그리고 달려라yarn lint-fix또는npm run lint-fix

아직 eslint를 설치하지 않은 경우 먼저 설치

npm install -g eslint

그럼 달려라

eslint --fix path/to/file.extension


주의: 해당 파일을 변경한 후에는 위의 명령을 매번 실행해야 합니다.

그렇지 않으면

extend(config, ctx) {
      // Run ESLint on save
      if (ctx.isDev && ctx.isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/,
          options: {
            fix: true
          }
        })
      }
    }
You. You can use this on the first page
    const colors = require('vuetify/es5/util/colors').default
    const pkg = require('./package')
    require('dotenv').config()

    module.exports = {
      mode: 'universal',
      /*
      ** Headers of the page
      */
      head: {
        titleTemplate: '%s - ' + process.env.npm_package_name,
        title: process.env.npm_package_name || '',
        meta: [
          { charset: 'utf-8' },
          { name: 'viewport', content: 'width=device-width, initial-scale=1' },
          {
            hid: 'description',
            name: 'description',
            content: process.env.npm_package_description || ''
          }
        ],
        link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
      },
      /*
      ** Customize the progress-bar color
      */
      loading: { color: '#fff' },
      /*
      ** Global CSS
      */
      css: [],
      /*
      ** Plugins to load before mounting the App
      */
      plugins: [],
      /*
      ** Nuxt.js dev-modules
      */
      buildModules: [
        // Doc: https://github.com/nuxt-community/eslint-module
        '@nuxtjs/eslint-module',
        '@nuxtjs/vuetify'
      ],
      /*
      ** Nuxt.js modules
      */
      modules: [
        // Doc: https://axios.nuxtjs.org/usage
        '@nuxtjs/axios',
        '@nuxtjs/pwa',
        // Doc: https://github.com/nuxt-community/dotenv-module
        '@nuxtjs/dotenv'
      ],
      /*
      ** Axios module configuration
      ** See https://axios.nuxtjs.org/options
      */
      axios: {},
      /*
      ** vuetify module configuration
      ** https://github.com/nuxt-community/vuetify-module
      */
      /*
      ** Build configuration
      */
      build: {
        extend(config, ctx) {
          // Run ESLint on save
          if (ctx.isDev && ctx.isClient) {
            config.module.rules.push({
              enforce: 'pre',
              test: /\.(js|vue)$/,
              loader: 'eslint-loader',
              exclude: /(node_modules)/,
              options: {
                fix: true
              }
            })
          }
        }
      }
    }

아직도 날 이해하지 못한다면.

난 그냥 내가 했던 것과 같은 문제가 있었어

eslint --fix fileName.extention

최초 설치 패키지: npm install -g eslint

그리고.

실행: eslint --fix

'--fix' 플래그를 사용해도 오류가 해결되지 않으면 ESlint 구성 파일에 오류가 있음을 의미합니다.파일을 다시 한 번 확인해 주세요.

언급URL : https://stackoverflow.com/questions/51265476/fix-doesnt-fix-the-errors-using-eslint

반응형