Skip to content
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

chore(gatsby): drop eslint-plugin-graphql #36364

Merged
merged 1 commit into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"eslint": "^7.32.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-flowtype": "^5.10.0",
"eslint-plugin-graphql": "^4.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.30.1",
Expand Down
12 changes: 1 addition & 11 deletions packages/gatsby/src/utils/eslint-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { printSchema, GraphQLSchema } from "graphql"
import { ESLint } from "eslint"
import path from "path"

Expand Down Expand Up @@ -37,7 +36,6 @@ export const eslintRequiredConfig: ESLint.Options = {
}

export const eslintConfig = (
schema: GraphQLSchema,
usingAutomaticJsxRuntime: boolean
): ESLint.Options => {
return {
Expand Down Expand Up @@ -69,7 +67,7 @@ export const eslintConfig = (
},
requireConfigFile: false,
},
plugins: [`graphql`],
plugins: [],
rules: {
// New versions of react use a special jsx runtime that remove the requirement
// for having react in scope for jsx. Once the jsx runtime is backported to all
Expand All @@ -79,14 +77,6 @@ export const eslintConfig = (
"react/jsx-uses-react": usingAutomaticJsxRuntime ? `off` : `error`,
"react/react-in-jsx-scope": usingAutomaticJsxRuntime ? `off` : `error`,
"import/no-webpack-loader-syntax": [0],
"graphql/template-strings": [
`error`,
{
env: `relay`,
schemaString: printSchema(schema, { commentDescriptions: true }),
tagName: `graphql`,
},
],
"react/jsx-pascal-case": [
`warn`,
{
Expand Down

This file was deleted.

12 changes: 5 additions & 7 deletions packages/gatsby/src/utils/webpack-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { getBrowsersList } from "./browserslist"
import ESLintPlugin from "eslint-webpack-plugin"
import { cpuCoreCount } from "gatsby-core-utils"
import { GatsbyWebpackStatsExtractor } from "./gatsby-webpack-stats-extractor"
import { GatsbyWebpackEslintGraphqlSchemaReload } from "./gatsby-webpack-eslint-graphql-schema-reload-plugin"
import {
GatsbyWebpackVirtualModules,
VIRTUAL_MODULES_BASE_PATH,
Expand All @@ -38,7 +37,7 @@ type ContextualRuleFactory<T = Record<string, unknown>> = RuleFactory<T> & {
external?: RuleFactory<T>
}

type PluginFactory = (...args: any) => WebpackPluginInstance
type PluginFactory = (...args: any) => WebpackPluginInstance | null

type BuiltinPlugins = typeof builtinPlugins

Expand Down Expand Up @@ -785,22 +784,21 @@ export const createWebpackUtils = (
plugins.extractStats = (): GatsbyWebpackStatsExtractor =>
new GatsbyWebpackStatsExtractor()

plugins.eslintGraphqlSchemaReload =
(): GatsbyWebpackEslintGraphqlSchemaReload =>
new GatsbyWebpackEslintGraphqlSchemaReload()
// TODO: remove this in v5
plugins.eslintGraphqlSchemaReload = (): null => null

plugins.virtualModules = (): GatsbyWebpackVirtualModules =>
new GatsbyWebpackVirtualModules()

plugins.eslint = (schema: GraphQLSchema): WebpackPluginInstance => {
plugins.eslint = (): WebpackPluginInstance => {
const options = {
extensions: [`js`, `jsx`],
exclude: [
`/node_modules/`,
`/bower_components/`,
VIRTUAL_MODULES_BASE_PATH,
],
...eslintConfig(schema, config.jsxRuntime === `automatic`),
...eslintConfig(config.jsxRuntime === `automatic`),
}
// @ts-ignore
return new ESLintPlugin(options)
Expand Down
5 changes: 1 addition & 4 deletions packages/gatsby/src/utils/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ module.exports = async (
new ForceCssHMRForEdgeCases(),
plugins.hotModuleReplacement(),
plugins.noEmitOnErrors(),
plugins.eslintGraphqlSchemaReload(),
new StaticQueryMapper(store),
])
.filter(Boolean)
Expand All @@ -266,12 +265,10 @@ module.exports = async (
}

const isCustomEslint = hasLocalEslint(program.directory)
// get schema to pass to eslint config and program for directory
const { schema } = store.getState()

// if no local eslint config, then add gatsby config
if (!isCustomEslint) {
configPlugins.push(plugins.eslint(schema))
configPlugins.push(plugins.eslint())
}

// Enforce fast-refresh rules even with local eslint config
Expand Down
Loading