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

Unexpected reserved word #175

Open
davidjbradshaw opened this issue Feb 4, 2016 · 6 comments
Open

Unexpected reserved word #175

davidjbradshaw opened this issue Feb 4, 2016 · 6 comments

Comments

@davidjbradshaw
Copy link

I get the following error when it sees the word 'import' in my code.

Error: Line 5: Unexpected reserved word
    at throwError (/usr/local/lib/node_modules/plato/node_modules/esprima/esprima.js:1156:21)
    at throwUnexpected (/usr/local/lib/node_modules/plato/node_modules/esprima/esprima.js:1204:17)
    at parsePrimaryExpression (/usr/local/lib/node_modules/plato/node_modules/esprima/esprima.js:1567:16)
    at /usr/local/lib/node_modules/plato/node_modules/esprima/esprima.js:3609:38
    at trackLeftHandSideExpressionAllowCall (/usr/local/lib/node_modules/plato/node_modules/esprima/esprima.js:3504:61)
    at parsePostfixExpression (/usr/local/lib/node_modules/plato/node_modules/esprima/esprima.js:1703:20)
    at /usr/local/lib/node_modules/plato/node_modules/esprima/esprima.js:3609:38
    at parseUnaryExpression (/usr/local/lib/node_modules/plato/node_modules/esprima/esprima.js:1784:16)
    at /usr/local/lib/node_modules/plato/node_modules/esprima/esprima.js:3609:38
    at parseMultiplicativeExpression (/usr/local/lib/node_modules/plato/node_modules/esprima/esprima.js:1790:20)
@aaronroberson
Copy link

I am also getting this error despite using the following eslintrc:

{
  "extends": "airbnb/base",
  "rules": {
    "comma-dangle": 0
  },
  "env": {
    "browser": true,
    "jasmine": true,
    "node": true
  },
  "globals": {
    "_": false
  }
}

I'm using the following config:

const paths: {
  plato: {
      output: './build/reports/complexity',
      options: {
        eslint: '.eslintrc',
        title: 'JavaScript Complexity Report',
        recurse: true
      }
    }
};

And executing in this way:

plato.inspect([
    'app.js',
    'gulpfile.babel.js',
    'src/app.js',
    'src/main.js',
    'src',
    'build'
  ], 
  paths.reports.plato.output, 
  paths.reports.plato.options,
  report => console.log(report)
);

@aaronroberson
Copy link

I don't get the errors when I use exec but the reports are empty:

exec(spawnSync('node_modules/plato/bin/plato', [
    '--dir',
    paths.reports.plato.output,
    '--recurse',
    '--title',
    'Plato Complexity Report',
    '--eslint',
    './.eslintrc',
    paths.root,
    'gulpfile.babel.js'
  ]));

@aaronroberson
Copy link

When I run from the command line I also get the Unexpected reserved word error at import:

plato --dir 'build/reports/complexity' --recurse --title 'JavaScript Complexity Report' --eslint './.eslintrc' 'src'

@vtovikram
Copy link

This is because Plato is not able to figure out ES6
try this out with a transpiler like (https://babeljs.io/repl/).
This should fix the problem and i think there is a es6 fork also from plato.

@aaronroberson
Copy link

@vtovikram Can you provide some steps on how to use Babel with plato? Are you suggesting that I run plato against my transpiled files or can I run it against my source code but somehow piped through Babel?

@vtovikram
Copy link

yeah i did run it against my transpiled files it Worked, but ended up not using it. but again debugging on that was much harder to get my numbers better so gave up on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants