ESLint analyzer doesn't support JS module files |
|||
Issue descriptionhttps://tricium-dev.appspot.com/run/5748022428303360 ESLint doesn't seem to parse JS module files correctly: > Parsing error: 'import' and 'export' may appear only with 'sourceType: module' https://chromium-review.googlesource.com/c/infra/infra/+/1357212/6/appengine/monorail/static/js/elements/mr-account-dropdown.js#1 I'm unsure if ESLint supports linting both JS module and non-JS module files in the same run.
,
Dec 6
Note, the docs I was just looking at was: https://eslint.org/docs/user-guide/configuring#specifying-parser-options The modified config would be: { "extends": "google", "env": { "es6": true }, "parserOptions": { "sourceType": "module" }, "rules": { "require-jsdoc": 0, "indent": ["error", 2] } } To test it on example files we can run $ eslint --parser-options='{"sourceType":"module"}' ... I just tried running it on a couple files that *didn't* have import, and didn't find any issues with that yet.
,
Dec 6
Relevant discussion: https://stackoverflow.com/questions/36367656/eslint-sourcetype-mixture-of-script-and-module Looks like the downside of using "module" with non-modules is the warning that "use strict" isn't necessary in modules. But with the google style config base, it seems like I'm not getting that warning anyway. So in this case the simple solution may be to just specify "module" source type. https://chromium-review.googlesource.com/c/infra/infra/+/1365935
,
Dec 7
The following revision refers to this bug: https://chromium.googlesource.com/infra/infra/+/9a310d0bb46c03c59d68b474e20990d0e8369686 commit 9a310d0bb46c03c59d68b474e20990d0e8369686 Author: Quinten Yearsley <qyearsley@chromium.org> Date: Fri Dec 07 00:10:44 2018 Switch default config for eslint to use "module" source type Bug: 912394 Change-Id: I7c0f0e84f8e4f4b442ab98e380dd6986f34034b0 Reviewed-on: https://chromium-review.googlesource.com/c/1365935 Commit-Queue: Quinten Yearsley <qyearsley@chromium.org> Reviewed-by: Jeff Carpenter <jeffcarp@chromium.org> Cr-Commit-Position: refs/heads/master@{#19404} [modify] https://crrev.com/9a310d0bb46c03c59d68b474e20990d0e8369686/go/src/infra/tricium/functions/eslint/test/example.js [modify] https://crrev.com/9a310d0bb46c03c59d68b474e20990d0e8369686/go/src/infra/tricium/functions/eslint/package-lock.json [modify] https://crrev.com/9a310d0bb46c03c59d68b474e20990d0e8369686/go/src/infra/tricium/functions/eslint/.eslintrc.json
,
Dec 7
Tricium now parses and checks JS module files, e.g. https://chromium-review.googlesource.com/c/infra/infra/+/1357212/8 |
|||
►
Sign in to add a comment |
|||
Comment 1 by qyears...@chromium.org
, Dec 6