Skip to content

Commit

Permalink
chore(gatsby): drop eslint-plugin-graphql (#36364)
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Aug 19, 2022
1 parent 2e67161 commit b361081
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 396 deletions.
1 change: 0 additions & 1 deletion packages/gatsby/package.json
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
@@ -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
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
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

0 comments on commit b361081

Please sign in to comment.