Skip to content

--fix-type along with plugins crashes #11586

@mysticatea

Description

@mysticatea

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.

Metadata

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlycoreRelates to ESLint's core APIs and features

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions