Skip to content

Commit

Permalink
Revert "fix(gatsby-plugin-typescript): Broader webpack support (gatsb…
Browse files Browse the repository at this point in the history
…yjs#22003)"

This reverts commit 4b93826.
  • Loading branch information
wardpeet committed Mar 16, 2020
1 parent c8be2ce commit 0018b95
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 48 deletions.
43 changes: 0 additions & 43 deletions packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down
6 changes: 1 addition & 5 deletions packages/gatsby-plugin-typescript/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down

0 comments on commit 0018b95

Please sign in to comment.