Errors running xo's own tests
See original GitHub issueI’m getting errors when running npm test
(or node main.js
) in the xo
repo. For every one of the files the test/
directory, I get this message when running any of those commands:
× 1:1 Parsing error: Unexpected token import
Here are my steps:
- Clone the repo and
cd
into it (the original or my fork) - Run
npm install
- Run
npm test
(ornode main.js
orxo
)
I get the same errors on two different computers:
- Windows 7 (32 bit)
- node: v10.6.0
- npm: 6.1.0
- git bash 4.4.12(2)-release (i686-pc-msys)
- Linux Mint 18.2 (32 bit)
- node: v10.7.0
- npm: 6.1.0
- bash 4.3.48(1)-release (i686-pc-linux-gnu)
Since the error message implies an issue with new-style module imports, I also tried node --experimental-modules main.js
, but got the same errors on both computers.
Since the README on GitHub shows a passing build, it would make sense if something is going wrong on my end, but I haven’t been able to figure out what it is. Since I’m getting this error consistently on multiple OSs and machines, I want to make sure there isn’t some setup step I’m missing (something with babel?) or if this is something other people are experiencing.
I’m working on a pull request unrelated to this issue, but I can’t effectively write tests to go with it at this point, since I’m getting parse errors on the test files themselves without making any changes.
Click for full test log (errors at the bottom)
> xo@0.21.1 test (/path/to/repo)
> node main.js && eslint . && nyc ava
test\fixtures\cwd\unicorn.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
lib\options-manager.js:170:21
‼ 170:21 Arrow function has a complexity of 25. complexity
‼ 229:3 Unexpected todo comment. no-warning-comments
test\fixtures\overrides\test\foo.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\overrides\test\bar.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\open-report\warnings\three.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\open-report\warnings\one.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\open-report\successes\success.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\open-report\errors\two-with-warnings.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\extends.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\gitignore\index.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\gitignore-multiple-negation\!!unicorn.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\gitignore-multiple-negation\!unicorn.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\ignores\index.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\negative-gitignore\foo.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\nested\file.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\overrides\index.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\project\file.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\gitignore\test\bar.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\ignores\test\foo.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\nodir\nested\index.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\open-report\errors\one.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\open-report\errors\three.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\fixtures\ignores\test\fixtures\linter-error.js:undefined:undefined
‼ 0:0 File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
test\options-manager.js:1:1
× 1:1 Parsing error: Unexpected token import
test\open-report.js:1:1
× 1:1 Parsing error: Unexpected token import
test\main.js:1:1
× 1:1 Parsing error: Unexpected token import
test\lint-text.js:1:1
× 1:1 Parsing error: Unexpected token import
test\lint-files.js:1:1
× 1:1 Parsing error: Unexpected token import
test\cli.js:1:1
× 1:1 Parsing error: Unexpected token import
24 warnings
6 errors
EDIT
I was able to successfully run npx nyc ava
, though it’s showing 8 failed tests. Still can’t successfully run xo
on the repo, though.
Click for full ava
test log
77 passed
1 known failure
8 failed
main » ignores fixture
main » overrides fixture
D:\Harper\js\xo\test\test\main.js:45
Threw:
Error {
cmd: 'D:\\Harper\\js\\xo\\main.js',
code: 1,
failed: true,
killed: false,
signal: null,
stderr: '',
stdout: `␊
test\\bar.js:1:1␊
× 1:1 Parsing error: Unexpected token import ␊
␊
test\\foo.js:1:1␊
× 1:1 Parsing error: Unexpected token import ␊
␊
2 errors␊
`,
timedOut: false,
message: `Command failed: D:\\Harper\\js\\xo\\main.js␊
␊
␊
test\\bar.js:1:1␊
× 1:1 Parsing error: Unexpected token import ␊
␊
test\\foo.js:1:1␊
× 1:1 Parsing error: Unexpected token import ␊
␊
2 errors␊
`,
}
Test.fn (test/main.js:45:10)
processEmit (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
processEmit (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
lint-text » JSX support
D:\Harper\js\xo\test\test\lint-text.js:82
Value is not `true`:
false
hasRule(results, 'no-unused-vars')
=> false
results
=> [
{
errorCount: 1,
filePath: '<text>',
fixableErrorCount: 0,
fixableWarningCount: 0,
messages: [
Object { … },
],
source: `const app = <div className="appClass">Hello, React!</div>;␊
`,
warningCount: 0,
},
]
Test.t [as fn] (test/lint-text.js:82:2)
processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
lint-text » plugin support
D:\Harper\js\xo\test\test\lint-text.js:90
Value is not `true`:
false
hasRule(results, 'react/jsx-no-undef')
=> false
results
=> [
{
errorCount: 1,
filePath: '<text>',
fixableErrorCount: 0,
fixableWarningCount: 0,
messages: [
Object { … },
],
source: `var React;␊
React.render(<App/>);␊
`,
warningCount: 0,
},
]
Test.t [as fn] (test/lint-text.js:90:2)
processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
lint-text » extends support
D:\Harper\js\xo\test\test\lint-text.js:102
Value is not `true`:
false
hasRule(results, 'react/jsx-no-undef')
=> false
results
=> [
{
errorCount: 1,
filePath: '<text>',
fixableErrorCount: 0,
fixableWarningCount: 0,
messages: [
Object { … },
],
source: `var React;␊
React.render(<App/>);␊
`,
warningCount: 0,
},
]
Test.t [as fn] (test/lint-text.js:102:2)
processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
lint-text » extends support with `esnext` option
D:\Harper\js\xo\test\test\lint-text.js:109
Value is not `true`:
false
hasRule(results, 'react/jsx-no-undef')
=> false
results
=> [
{
errorCount: 1,
filePath: '<text>',
fixableErrorCount: 0,
fixableWarningCount: 0,
messages: [
Object { … },
],
source: `import path from 'path';␊
let React;␊
React.render(<App/>);␊
`,
warningCount: 0,
},
]
Test.t [as fn] (test/lint-text.js:109:2)
processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
lint-text » disable style rules when `prettier` option is enabled
D:\Harper\js\xo\test\node_modules\prettier\index.js:7058
Error thrown in test:
Error (UndefinedParserError) {
message: 'No parser could be inferred for file: <text>',
}
normalize (node_modules/prettier/index.js:7058:15)
formatWithCursor (node_modules/prettier/index.js:10378:12)
node_modules/prettier/index.js:31222:15
Object.format (node_modules/prettier/index.js:31241:12)
Program (node_modules/eslint-plugin-prettier/eslint-plugin-prettier.js:415:45)
listeners.(anonymous function).forEach.listener (node_modules/eslint/lib/util/safe-emitter.js:45:58)
Object.emit (node_modules/eslint/lib/util/safe-emitter.js:45:38)
NodeEventGenerator.applySelector (node_modules/eslint/lib/util/node-event-generator.js:251:26)
NodeEventGenerator.applySelectors (node_modules/eslint/lib/util/node-event-generator.js:280:22)
NodeEventGenerator.enterNode (node_modules/eslint/lib/util/node-event-generator.js:294:14)
CodePathAnalyzer.enterNode (node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)
nodeQueue.forEach.traversalInfo (node_modules/eslint/lib/linter.js:861:28)
runRules (node_modules/eslint/lib/linter.js:857:15)
Linter._verifyWithoutProcessors (node_modules/eslint/lib/linter.js:993:31)
lint-text » extends `react` support with `prettier` option
D:\Harper\js\xo\test\test\lint-text.js:131
Value is not `true`:
false
hasRule(results, 'prettier/prettier')
=> false
results
=> [
{
errorCount: 1,
filePath: '<text>',
fixableErrorCount: 0,
fixableWarningCount: 0,
messages: [
Object { … },
],
source: `<Hello name={ firstname } />;␊
`,
warningCount: 0,
},
]
Test.t [as fn] (test/lint-text.js:131:2)
processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
lint-text » lintText() - overrides support
D:\Harper\js\xo\test\test\lint-text.js:150
[object Object]
Difference:
- 1
+ 0
---------------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---------------------|----------|----------|----------|----------|-------------------|
All files | 95.7 | 93.08 | 100 | 95.57 | |
xo | 90.99 | 85.19 | 100 | 90.91 | |
cli.js | 62.5 | 40 | 100 | 62.5 | 11,12,13 |
index.js | 100 | 100 | 100 | 100 | |
main.js | 82.93 | 79.17 | 100 | 82.93 |... 34,151,152,164 |
xo/config | 100 | 100 | 100 | 100 | |
plugins.js | 100 | 100 | 100 | 100 | |
xo/lib | 98.8 | 97.14 | 100 | 98.75 | |
open-report.js | 96.15 | 92.86 | 100 | 95.45 | 22 |
options-manager.js | 99.29 | 97.8 | 100 | 99.28 | 249 |
---------------------|----------|----------|----------|----------|-------------------|
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (8 by maintainers)
Fixed in #344
Hmm, then the cache sounds like a dead end in this case (I did try one more time, but got the same thing).
I’ve been trying to narrow things down by manually running the content of the tests that are failing on my end. I’m now wondering if this has something to do with eslint, possibly along with using plugins, though I still don’t know why this is working differently for me than everyone else.
I found that all tests with React syntax fail for me with the message
Parsing error: Unexpected token <
. This includes the following tests:esnext
optionreact
support withprettier
optionOne example, ‘plugin support’, which is just testing for the use of the
no-unused-vars
rule but is only seeingnull
for aruleId
:Using prettier actually threw an error. This is replicating a portion of ‘disable style rules when
prettier
option is enabled’ and the error is being thrown by eslint:This seems to line up with the failure to interpret
import
statements as valid. This shows up in another failing-for-me test, ‘overrides fixture’, which is only expecting this call not to throw an error:I haven’t been able to isolate where the breakdown is yet. With a bit of
console.log
, I can see that the passed-in options are being applied toengine
, the instance of eslintCLIEngine, but the errors show up when the next line in that file is run.I searched through eslint’s issues, but didn’t find anything related there and it’s still throwing me for a loop that I’m having this issue consistently on multiple OSs, but no one else seems to be getting the errors or failing tests that I am. I’d create an issue in eslint, but I don’t yet know how to simplify an example specific to that project that would show this issue, since I still can’t tell exactly what the issue is.
If you have any other ideas, I’d be happy to try them. Otherwise, I’m thinking I’ll just try to make the test cases for my PR pass and see what the CI thinks when I submit it.