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

Error whilst trying to use plugin with babel-eslint #189

Closed
Robula opened this issue Sep 21, 2017 · 9 comments
Closed

Error whilst trying to use plugin with babel-eslint #189

Robula opened this issue Sep 21, 2017 · 9 comments

Comments

@Robula
Copy link

Robula commented Sep 21, 2017

Tell us about your environment

  • ESLint Version: 4.7.1
  • eslint-plugin-vue Version: 3.13.0
  • Node Version: 8.5.0
  • babel-eslint Version: 8.0.0

Windows 10 15063 😞

Please show your full configuration:

{
    "parserOptions": {
        "parser": "babel-eslint",
        "ecmaVersion": 2017,
        "sourceType": "module"
    },
    "plugins": ["vue"],
    "extends": [
        "eslint:recommended",
        "plugin:vue/recommended"
    ],
    "rules": { }
}

What did you do? Please include the actual source code causing the issue.

eslint --ext .js,.vue src/**/*"

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

Cannot read property 'loc' of null
TypeError: Cannot read property 'loc' of null
    at checkForBreakAfter (D:\app\node_modules\eslint\lib\rules\no-unexpected-multiline.js:51:63)
    at EventEmitter.CallExpression (D:\app\node_modules\eslint\lib\rules\no-unexpected-multiline.js:80:17)
    at emitOne (events.js:120:20)
    at EventEmitter.emit (events.js:210:7)
    at NodeEventGenerator.applySelector (D:\app\node_modules\eslint\lib\util\node-event-generator.js:265:26)
    at NodeEventGenerator.applySelectors (D:\app\node_modules\eslint\lib\util\node-event-generator.js:294:22)
    at NodeEventGenerator.enterNode (D:\app\node_modules\eslint\lib\util\node-event-generator.js:308:14)
    at CodePathAnalyzer.enterNode (D:\app\node_modules\eslint\lib\code-path-analysis\code-path-analyzer.js:606:23)
    at nodeQueue.forEach.traversalInfo (D:\app\node_modules\eslint\lib\linter.js:985:32)
    at Array.forEach (<anonymous>)
@mysticatea
Copy link
Member

Thank you for this report.

  1. Your babel-eslint seems too old version (yours is 4.7.1 but latest is 8.0.0). Could you confirm that it happens with the latest babel-eslint?
  2. Could you share the source code to reproduce it? You can --debug option to know the file which happens the error.

@Robula
Copy link
Author

Robula commented Sep 21, 2017

Hi @mysticatea. My apologies, was a bad copy+paste. I have updated my question with the correct version.

Thank you for suggesting the --debug switch. Using that I have created a new file to replicate the error and have discovered that using an JS Decorator with a object body is causing the error.

This .vue passes linting without error.

<template>
    <div></div>
</template>

<script>
import Vue from 'vue';
import Component from 'vue-class-component';

@Component()
export default class LintThis extends Vue { }
</script>

This .vue fails linting with the original error. The only difference is the options object passed to the decorator.

<template>
    <div></div>
</template>

<script>
import Vue from 'vue';
import Component from 'vue-class-component';

@Component({})
export default class LintThis extends Vue { }
</script>
$ eslint --debug src/lintthis.vue
  eslint:cli Running on files +0ms
  eslint:glob-util Creating list of files to process. +0ms
  eslint:ignored-paths Looking for ignore file in D:\app +0ms
  eslint:ignored-paths Could not find ignore file in cwd +1ms
  eslint:cli-engine Processing D:\app\src\lintthis.vue +0ms
  eslint:cli-engine Linting D:\app\src\lintthis.vue +1ms
  eslint:config Constructing config file hierarchy for D:\app\src +0ms
  eslint:config Using .eslintrc and package.json files +1ms
  eslint:config Loading D:\app\.eslintrc.json +3ms
  eslint:config-file Loading JSON config file: D:\app\.eslintrc.json +0ms
  eslint:config-file Loading plugin:vue/recommended +184ms
  eslint:config-file Attempting to resolve eslint-plugin-vue +2ms
  eslint:config-file Loading JS config file: D:\app\node_modules\eslint-plugin-vue\lib\index.js +1ms
  eslint:config-file Loading D:\app\node_modules\eslint-plugin-vue\lib\config\base.js +31ms
  eslint:config-file Loading JS config file: D:\app\node_modules\eslint-plugin-vue\lib\config\base.js +2ms
  eslint:config-file Loading D:\app\node_modules\eslint\conf\eslint-recommended.js +1ms
  eslint:config-file Loading JS config file: D:\app\node_modules\eslint\conf\eslint-recommended.js +1ms
  eslint:config Using D:\app\.eslintrc.json +324ms
  eslint:config-ops Using config from partial cache +0ms
  eslint:config-ops Apply environment settings to config +2ms
  eslint:config-ops Creating config for environment browser +0ms
  eslint:config-ops Creating config for environment es6 +1ms
  eslint:linter Linting code for D:\app\src\lintthis.vue (pass 1) +0ms
Cannot read property 'loc' of null
TypeError: Cannot read property 'loc' of null
    at checkForBreakAfter (D:\app\node_modules\eslint\lib\rules\no-unexpected-multiline.js:51:63)
    at EventEmitter.CallExpression (D:\app\node_modules\eslint\lib\rules\no-unexpected-multiline.js:80:17)
    at emitOne (events.js:120:20)
    at EventEmitter.emit (events.js:210:7)
    at NodeEventGenerator.applySelector (D:\app\node_modules\eslint\lib\util\node-event-generator.js:265:26)
    at NodeEventGenerator.applySelectors (D:\app\node_modules\eslint\lib\util\node-event-generator.js:294:22)
    at NodeEventGenerator.enterNode (D:\app\node_modules\eslint\lib\util\node-event-generator.js:308:14)
    at CodePathAnalyzer.enterNode (D:\app\node_modules\eslint\lib\code-path-analysis\code-path-analyzer.js:606:23)
    at nodeQueue.forEach.traversalInfo (D:\app\node_modules\eslint\lib\linter.js:985:32)
    at Array.forEach (<anonymous>)

Just for reference, here is my .babelrc file

{
  "presets": [["env", { "modules": false }], "stage-2" ],
  "plugins": ["transform-runtime", "transform-decorators-legacy", "transform-class-properties"]
}

It seems that in my case, eslint-plugin-vue isn't playing nicely with babel-eslint when using experimental decorators that have one or more parameters.

@mysticatea
Copy link
Member

Thank you for the information.

Hmm, but weird, I could not reproduce it...

~\dev\sandbox> npm ls eslint; npm ls eslint-plugin-vue; npm ls babel-eslint
[email protected] C:\Users\t-nagashima.MSS\dev\sandbox
`-- [email protected]

[email protected] C:\Users\t-nagashima.MSS\dev\sandbox
`-- [email protected]

[email protected] C:\Users\t-nagashima.MSS\dev\sandbox
`-- [email protected]

~\dev\sandbox> cat .eslintrc.json
{
    "parserOptions": {
        "parser": "babel-eslint",
        "ecmaVersion": 2017,
        "sourceType": "module"
    },
    "plugins": [
        "vue"
    ],
    "extends": [
        "eslint:recommended",
        "plugin:vue/recommended"
    ],
    "rules": {}
}
~\dev\sandbox> cat test.vue
<template>
    <div></div>
</template>

<script>
import Vue from 'vue';
import Component from 'vue-class-component';

@Component({})
export default class LintThis extends Vue { }
</script>
~\dev\sandbox> eslint --debug test.vue
  eslint:cli Running on files +0ms
  eslint:glob-util Creating list of files to process. +0ms
  eslint:ignored-paths Looking for ignore file in C:\Users\t-nagashima.MSS\dev\sandbox +0ms
  eslint:ignored-paths Could not find ignore file in cwd +1ms
  eslint:cli-engine Processing C:\Users\t-nagashima.MSS\dev\sandbox\test.vue +0ms
  eslint:cli-engine Linting C:\Users\t-nagashima.MSS\dev\sandbox\test.vue +0ms
  eslint:config Constructing config file hierarchy for C:\Users\t-nagashima.MSS\dev\sandbox +0ms
  eslint:config Using .eslintrc and package.json files +0ms
  eslint:config Loading C:\Users\t-nagashima.MSS\dev\sandbox\.eslintrc.json +1ms
  eslint:config-file Loading JSON config file: C:\Users\t-nagashima.MSS\dev\sandbox\.eslintrc.json +0ms
  eslint:config-file Loading plugin:vue/recommended +66ms
  eslint:config-file Attempting to resolve eslint-plugin-vue +1ms
  eslint:config-file Loading JS config file: C:\Users\t-nagashima.MSS\dev\sandbox\node_modules\eslint-plugin-vue\lib\index.js +0ms
  eslint:config-file Loading C:\Users\t-nagashima.MSS\dev\sandbox\node_modules\eslint-plugin-vue\lib\config\base.js +14ms
  eslint:config-file Loading JS config file: C:\Users\t-nagashima.MSS\dev\sandbox\node_modules\eslint-plugin-vue\lib\config\base.js +0ms
  eslint:config-file Loading C:\Users\t-nagashima.MSS\dev\sandbox\node_modules\eslint\conf\eslint-recommended.js +2ms
  eslint:config-file Loading JS config file: C:\Users\t-nagashima.MSS\dev\sandbox\node_modules\eslint\conf\eslint-recommended.js +0ms
  eslint:config Using C:\Users\t-nagashima.MSS\dev\sandbox\.eslintrc.json +125ms
  eslint:config-ops Using config from partial cache +0ms
  eslint:config-ops Apply environment settings to config +0ms
  eslint:config-ops Creating config for environment browser +1ms
  eslint:config-ops Creating config for environment es6 +0ms
  eslint:linter Linting code for C:\Users\t-nagashima.MSS\dev\sandbox\test.vue (pass 1) +0ms
  eslint:linter Generating fixed text for C:\Users\t-nagashima.MSS\dev\sandbox\test.vue (pass 1) +232ms
  eslint:text-fixer Applying fixes +0ms
  eslint:text-fixer shouldFix parameter was false, not attempting fixes +1ms
  eslint:cli-engine Linting complete in: 372ms +367ms
~\dev\sandbox>

@michalsnik
Copy link
Member

Hey @Robula did you manage to figure out what was wrong?

@Robula
Copy link
Author

Robula commented Oct 10, 2017

@michalsnik No I couldn't resolve it, however I have just moved over to OSX as my primary development machine so I will try again and report back here.
Thanks.

@michalsnik
Copy link
Member

Any luck @Robula ?

@Robula
Copy link
Author

Robula commented Nov 6, 2017

Hi @michalsnik. Sorry for not reporting back here. I have been working on Vue projects without including this plugin. I had thought it may have been a glitch working on a Windows system but this is not the case as even on my new non Windows environment (OS X) I am still experiencing the same issue. I haven't tested this on a fresh project, but I will do so when I get some free time.

Here is the output;

robs-mbp:App rob$ node ./node_modules/eslint/bin/eslint.js --debug ./src/app.vue
  eslint:cli Running on files +0ms
  eslint:glob-util Creating list of files to process. +16ms
  eslint:ignored-paths Looking for ignore file in /Users/rob/DEV/App +2ms
  eslint:ignored-paths Could not find ignore file in cwd +0ms
  eslint:cli-engine Processing /Users/rob/DEV/App/src/app.vue +3ms
  eslint:cli-engine Linting /Users/rob/DEV/App/src/app.vue +1ms
  eslint:config Constructing config for /Users/rob/DEV/App/src/app.vue +0ms
  eslint:config Using .eslintrc and package.json files +0ms
  eslint:config Loading /Users/rob/DEV/App/src/.eslintrc +1ms
  eslint:config-file Loading config file: /Users/rob/DEV/App/src/.eslintrc +0ms
  eslint:config Using /Users/rob/DEV/App/src/.eslintrc +46ms
  eslint:config Loading /Users/rob/DEV/App/.eslintrc +0ms
  eslint:config-file Loading config file: /Users/rob/DEV/App/.eslintrc +0ms
  eslint:config-file Loading plugin:vue/recommended +10ms
  eslint:config-file Attempting to resolve eslint-plugin-vue +0ms
  eslint:config-file Loading JS config file: /Users/rob/DEV/App/node_modules/eslint-plugin-vue/lib/index.js +1ms
  eslint:config-file Loading /Users/rob/DEV/App/node_modules/eslint-plugin-vue/lib/config/base.js +45ms
  eslint:config-file Loading JS config file: /Users/rob/DEV/App/node_modules/eslint-plugin-vue/lib/config/base.js +0ms
  eslint:config-file Loading /Users/rob/DEV/App/node_modules/eslint/conf/eslint-recommended.js +2ms
  eslint:config-file Loading JS config file: /Users/rob/DEV/App/node_modules/eslint/conf/eslint-recommended.js +0ms
  eslint:config Using /Users/rob/DEV/App/.eslintrc +39ms
  eslint:config Merging command line environment settings +0ms
  eslint:config-ops Apply environment settings to config +0ms
  eslint:config-ops Creating config for environment browser +1ms
  eslint:config-ops Creating config for environment es6 +0ms
  eslint:config-ops Creating config for environment node +0ms
  eslint:config-ops Creating config for environment commonjs +0ms
Cannot read property 'loc' of null
TypeError: Cannot read property 'loc' of null
    at checkForBreakAfter (/Users/rob/DEV/App/node_modules/eslint/lib/rules/no-unexpected-multiline.js:48:64)
    at EventEmitter.CallExpression (/Users/rob/DEV/App/node_modules/eslint/lib/rules/no-unexpected-multiline.js:77:17)
    at emitOne (events.js:121:20)
    at EventEmitter.emit (events.js:211:7)
    at NodeEventGenerator.applySelector (/Users/rob/DEV/App/node_modules/eslint/lib/util/node-event-generator.js:265:26)
    at NodeEventGenerator.applySelectors (/Users/rob/DEV/App/node_modules/eslint/lib/util/node-event-generator.js:294:22)
    at NodeEventGenerator.enterNode (/Users/rob/DEV/App/node_modules/eslint/lib/util/node-event-generator.js:308:14)
    at CodePathAnalyzer.enterNode (/Users/rob/DEV/App/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:602:23)
    at CommentEventGenerator.enterNode (/Users/rob/DEV/App/node_modules/eslint/lib/util/comment-event-generator.js:98:23)
    at Traverser.enter (/Users/rob/DEV/App/node_modules/eslint/lib/eslint.js:929:36)
robs-mbp:App rob$

Here are my current working and non-working configurations.
This works (no eslint-plugin-vue):

{
    "parser": "babel-eslint",
    "parserOptions": {
        "ecmaVersion": 8,
        "sourceType": "module"
    },
    "env": {
        "commonjs": true
    },
    "extends": [
        "eslint:recommended"
    ]
}

This produces the error:

{
    "parserOptions": {
        "parser": "babel-eslint",
        "ecmaVersion": 8,
        "sourceType": "module"
    },
    "env": {
        "commonjs": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:vue/recommended"
    ]
}

@Robula
Copy link
Author

Robula commented Nov 9, 2017

@mysticatea @michalsnik OK, I went and created a new project to replicate this. I'll post a screenshot showing my exact setup and project as well as the results.

screen shot 2017-11-09 at 14 36 11
Please let me know if there you require any more information.
Many thanks.

@Robula
Copy link
Author

Robula commented Nov 9, 2017

I am closing this as this issue is not related to eslint-plugin-vue.
I have reopened this issue here: vuejs/vue-eslint-parser#21

Thanks to all involved.

@Robula Robula closed this as completed Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants