-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Custom ESLint rules #2446
Comments
There are few things I think we can do to mitigate this. I think the first important step is to release an eslint-config-gatsby that sets up all the relevant globals, "core" module, and the like |
@jquense That's a great idea for the But I still don't see any good solution for the disabled rules. |
the other's are easy enough to handle with a config i thinl, though i don't quite understand these concerns:
what is |
About gatsby pluginsIf I'm right, plugins which have a gatsby version (such as For instance, take the official example of Styled Component: it's only using package.json "dependencies": {
"gatsby": "latest",
"gatsby-plugin-styled-components": "latest",
}, In a component, you still import the original plugin, and not the gatsby version: MyComponent.jsx import styled from "styled-components"; This package is loaded from the gatsby plugin itself which has a ... Firing the ESLint
I can see two solutions for that:
About Webpack resolvingFile extensionsFixed by the following ESLint rule: "import/extensions" : ["error", { "jsx": "never" } ] AliasesWe have several directories in the In order to use them from any file while avoiding the A temporary solution is to disable this ESLint rule, but it's an open door for real unresolved errors:
@jquense Is that more understandable? :) |
So i think some of the problem here is that we've chosen a small convenience at the expense of defeating tools and best practices. Frankly I think that Gatsby should not provide these modules without you installing them. Take the |
Yeah… with starters and us giving the npm install instructions in packages — people shouldn't have too much trouble getting the right packages installed. Perhaps make this switch for v2? |
- Remove react-helmet from dependencies - Add react-helmet from peerDependencies BREAKING CHANGE: Requires that react-helmet is installed alongside gatsby-plugin-react-helmet. re gatsbyjs#2446
- Remove react-helmet from dependencies - Add react-helmet from peerDependencies BREAKING CHANGE: Requires that react-helmet is installed alongside gatsby-plugin-react-helmet. re #2446
For what it is worth, I created this for linting my own projects: https://www.npmjs.com/package/eslint-config-gatsby-standard |
Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open! |
Environment
The problem
Context
Hi folks,
I got a generic ESLint configuration for
ReactJS
based projects that I'm using on a Gatsby-based project.ESLint has no clue about Gatsby's webpack existence and fires some false-positives because of three main issues:
.jsx
) causingimport/no-unresolved
errors/helpers/
) causingimport/no-unresolved
errorsgatsby-plugin-...
version of plugins (e.g.styled-components
), but importingoriginal-plugin
in the project causingno-extraneous-dependencies
errorsgatsby-node.js
Ugly fix
We can fix the third issue by declaring
core-modules
like that (not so clean & difficult to maintain):The two other rules are temporary (?) disabled...
--> Is there any clean solution (other than this) ?
Related to
#463
#1990
#362
The text was updated successfully, but these errors were encountered: