Skip to content

Errors running xo's own tests #340

@noahbrenner

Description

@noahbrenner

I'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 (or node main.js or xo)

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)
> [email protected] 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 |
---------------------|----------|----------|----------|----------|-------------------|

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions