From 0018b9564f3a9b2918c3438f893257f66ee2caa2 Mon Sep 17 00:00:00 2001 From: Ward Peeters Date: Mon, 16 Mar 2020 11:30:27 +0100 Subject: [PATCH] Revert "fix(gatsby-plugin-typescript): Broader webpack support (#22003)" This reverts commit 4b9382663771b8e9bbe7e84179547ff369832212. --- .../src/__tests__/gatsby-node.js | 43 ------------------- .../src/gatsby-node.js | 6 +-- 2 files changed, 1 insertion(+), 48 deletions(-) diff --git a/packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js b/packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js index 4f31701a182ac..af2fa62a1dee5 100644 --- a/packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js +++ b/packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js @@ -89,49 +89,6 @@ describe(`gatsby-plugin-typescript`, () => { }) }) - it(`sets the correct webpack config with rule.loader shortcut`, () => { - const actions = { setWebpackConfig: jest.fn() } - const jsLoader = {} - const loaders = { js: jest.fn(() => jsLoader) } - const stage = `develop` - const webpackConfig = { - module: { - rules: [ - { - enforce: `pre`, - test: /\.jsx?$/, - exclude: /(node_modules|bower_components)/, - loader: `eslint-loader`, - }, - ], - }, - } - const getConfig = jest.fn(() => webpackConfig) - onCreateWebpackConfig({ actions, getConfig, loaders, stage }) - expect(actions.setWebpackConfig).toHaveBeenCalledWith({ - module: { - rules: [ - { - test: /\.tsx?$/, - use: jsLoader, - }, - ], - }, - }) - expect(actions.setWebpackConfig).toHaveBeenCalledWith({ - module: { - rules: [ - { - enforce: `pre`, - test: /\.tsx?$/, - exclude: /(node_modules|bower_components)/, - loader: `eslint-loader`, - }, - ], - }, - }) - }) - it(`does not set the webpack config if there isn't a js loader`, () => { const actions = { setWebpackConfig: jest.fn() } const loaders = { js: jest.fn() } diff --git a/packages/gatsby-plugin-typescript/src/gatsby-node.js b/packages/gatsby-plugin-typescript/src/gatsby-node.js index 4704be8de533d..fb6330cf935f0 100644 --- a/packages/gatsby-plugin-typescript/src/gatsby-node.js +++ b/packages/gatsby-plugin-typescript/src/gatsby-node.js @@ -53,11 +53,7 @@ function onCreateWebpackConfig({ if (isTypescriptDepAvailable) { const builtInEslintRule = getConfig().module.rules.find(rule => { if (rule.enforce === `pre`) { - if (rule.use) { - return rule.use.some(use => /eslint-loader/.test(use.loader)) - } else { - return /eslint-loader/.test(rule.loader) - } + return rule.use.some(use => /eslint-loader/.test(use.loader)) } return false })