question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ESLint warnings in file that doesn't exist

See original GitHub issue

Description

I’m getting ESLint warnings in a file that doesn’t seem to exist when adding and configuring ESLint using https://www.gatsbyjs.org/packages/gatsby-plugin-eslint/ and https://www.npmjs.com/package/eslint-plugin-react-app.

warn ESLintError:
/Users/mrseanbaines/projects/gatsby-eslint/_this_is_virtual_fs_path_/$virtual/sync-requires.js
  4:30  warning  Unexpected mix of '&&' and '||'  no-mixed-operators
  4:43  warning  Unexpected mix of '&&' and '||'  no-mixed-operators
Screenshot 2020-08-09 at 20 46 04

Steps to reproduce

npx gatsby new gatsby-eslint
cd gatsby-eslint
yarn add -D gatsby-plugin-eslint eslint-loader eslint eslint-plugin-react-app
touch .eslintrc

Add the following to .eslintrc:

{
  "extends": ["plugin:react-app/recommended"]
}

Add the plugin to gatsby-config.js:

  plugins: [
+   `gatsby-plugin-eslint`,
    ...
yarn start

Minimal Reproduction: https://github.com/mrseanbaines/gatsby-eslint

Expected result

No ESLint warnings for files that don’t exist

Actual result

ESLint warnings in file that doesn’t exist

Environment


  System:
    OS: macOS 10.15.6
    CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.17.0 - ~/.nvm/versions/node/v12.17.0/bin/node
    Yarn: 1.22.4 - ~/.yarn/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v12.17.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 84.0.4147.105
    Firefox: 78.0.2
    Safari: 13.1.2
  npmPackages:
    gatsby: ^2.24.26 => 2.24.26 
    gatsby-image: ^2.4.14 => 2.4.14 
    gatsby-plugin-eslint: ^2.0.8 => 2.0.8 
    gatsby-plugin-manifest: ^2.4.21 => 2.4.21 
    gatsby-plugin-offline: ^3.2.21 => 3.2.21 
    gatsby-plugin-react-helmet: ^3.3.10 => 3.3.10 
    gatsby-plugin-sharp: ^2.6.24 => 2.6.24 
    gatsby-source-filesystem: ^2.3.23 => 2.3.23 
    gatsby-transformer-sharp: ^2.5.12 => 2.5.12 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
piehcommented, Aug 11, 2020

Opened https://github.com/gatsbyjs/gatsby/pull/26356 to fix this the no-mixed-operators problem. Thank you very much @mrseanbaines for the reproduction showcasing the issue.

I do think that using “ignore” options is better overall (as the more custom eslint rules can still cause more warnings/errors as showcased by logs from @bluenex). Seeing that gatsby-plugin-eslint does set some default exclude ( https://github.com/mongkuen/gatsby-plugin-eslint/blob/master/src/gatsby-node.js ), I might either create pull request in the plugin … or adjust the “virtual” file path to contain .cache which should restore behaviours before the switch to virtual modules

1reaction
piehcommented, Aug 11, 2020

I’ll reopen the issue, as the just published hot-fix handles one specific instance of it, but didn’t fix it for all cases (second comment). So this need more involved follow up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how can I get warnings when importing modules that don't exist
If you are using eslint as your linter, you can use eslint-plugin-import . This plugin intends to support linting of ES2015+ (ES6+) ...
Read more >
Ignoring Code - ESLint - Pluggable JavaScript Linter
Ignored File Warnings ... This message occurs because ESLint is unsure if you wanted to actually lint the file or not. As the...
Read more >
ESLint --ignore-pattern is not working if file .eslintignore is not ...
ESLint --ignore-pattern is not working if file .eslintignore is not exists · Install ESLint (11.0.1 is the last at this moment) · Create...
Read more >
Migrate from TSLint to ESLint - Visual Studio Code
Hint: ESLint is sometimes "more correct" in how it does things and you may see warnings that you didn't have before, for example...
Read more >
Common React TypeScript ESLint / Lint Errors & Warning ...
Another option is to adjust the .eslintrc rules as well as ignore files and folders with .eslintignore. You can also run the command...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found