Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--fix-type along with plugins crashes #11586

Closed
mysticatea opened this issue Apr 4, 2019 · 0 comments · Fixed by #11546
Closed

--fix-type along with plugins crashes #11586

mysticatea opened this issue Apr 4, 2019 · 0 comments · Fixed by #11546
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features

Comments

@mysticatea
Copy link
Member

mysticatea commented Apr 4, 2019

From vuejs/eslint-plugin-vue#765.

Tell us about your environment

  • ESLint Version: 5.16.0
  • Node Version: 10.15.3, 11.9.0
  • npm Version: 6.9.0

What parser (default, Babel-ESLint, etc.) are you using?

  • vue-eslint-parser with babel-eslint

Please show your full configuration:

Configuration
{
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "rules": {
        "quotes": [ 2, "single" ],
         "vue/component-name-in-template-casing": [
         1,
         "PascalCase",
         {
            "registeredComponentsOnly": true
         }
      ],
      "vue/html-indent": [
         1,
         "tab",
         {
            "attribute": 1,
            "baseIndent": 1,
            "closeBracket": 1,
            "alignAttributesVertically": true
         }
      ]
    },
    "parserOptions": {
      "parser": "babel-eslint"
    }
  }

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Source Code
<template>
    <div id="app">
        <img :alt="Vue logo" src="./assets/logo.png">
        <HelloWorld msg="Welcome to Your Vue.js App"/>
    </div>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue'

export default {
  name: 'app',
  components: { HelloWorld, },
    data () {
        return { allum:3,row:'hi',jelly:8 }
    }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
./node_modules/eslint/bin/eslint.js --debug --fix --fix-type layout src/App.vue

What did you expect to happen?

Works fine.

What actually happened? Please include the actual, raw output from ESLint.

Crashed:

TypeError: Cannot read property 'meta' of undefined
    at CLIEngine.options.fix.lintResult (/home/fvhockney/laut/eslint-test/node_modules/eslint/lib/cli-engine.js:499:38)
    at Function.SourceCodeFixer.applyFixes (/home/fvhockney/laut/eslint-test/node_modules/eslint/lib/util/source-code-fixer.js:122:52)
    at Linter.verifyAndFix (/home/fvhockney/laut/eslint-test/node_modules/eslint/lib/linter.js:1050:43)
    at processText (/home/fvhockney/laut/eslint-test/node_modules/eslint/lib/cli-engine.js:197:32)
    at processFile (/home/fvhockney/laut/eslint-test/node_modules/eslint/lib/cli-engine.js:241:12)
    at fileList.map.fileInfo (/home/fvhockney/laut/eslint-test/node_modules/eslint/lib/cli-engine.js:616:40)
    at Array.map (<anonymous>)
    at CLIEngine.executeOnFiles (/home/fvhockney/laut/eslint-test/node_modules/eslint/lib/cli-engine.js:588:34)
    at Object.execute (/home/fvhockney/laut/eslint-test/node_modules/eslint/lib/cli.js:205:111)
    at Object.<anonymous> (/home/fvhockney/laut/eslint-test/node_modules/eslint/bin/eslint.js:78:28)

Because the CLIEngine#executeOnFiles() method makes the cache of rules before loading any config files.

eslint/lib/cli-engine.js

Lines 498 to 499 in 63fead8

const rule = this._rulesCache.get(lintResult.ruleId);
const matches = rule.meta && fixTypes.has(rule.meta.type);

eslint/lib/cli-engine.js

Lines 611 to 616 in 63fead8

this._rulesCache = this.getRules();
}
debug(`Processing ${fileInfo.filename}`);
const { result, config } = processFile(fileInfo.filename, configHelper, options, this.linter);

Are you willing to submit a pull request to fix this bug?

#11546 fixes this bug in fortune.

@mysticatea mysticatea added bug ESLint is working incorrectly core Relates to ESLint's core APIs and features accepted There is consensus among the team that this change meets the criteria for inclusion labels Apr 4, 2019
@mysticatea mysticatea self-assigned this Apr 13, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 7, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Nov 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant