Skip to content

Commit 43ad085

Browse files
authoredMar 19, 2020
chore(gatsby): Convert local-eslint-config-finder to typescript (#22403)
1 parent 0700cd5 commit 43ad085

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed
 

‎packages/gatsby/src/utils/gatsby-webpack-eslint-graphql-schema-reload-plugin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
const { store } = require(`../redux`)
88
const eslintConfig = require(`./eslint-config`)
9-
const hasLocalEslint = require(`./local-eslint-config-finder`)
9+
const { hasLocalEslint } = require(`./local-eslint-config-finder`)
1010

1111
const isEslintRule = rule => {
1212
const options = rule && rule.use && rule.use[0] && rule.use[0].options

‎packages/gatsby/src/utils/local-eslint-config-finder.js ‎packages/gatsby/src/utils/local-eslint-config-finder.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
const path = require(`path`)
2-
const glob = require(`glob`)
3-
const debug = require(`debug`)(`gatsby:webpack-eslint-config`)
4-
const report = require(`gatsby-cli/lib/reporter`)
1+
import path from "path"
2+
import glob from "glob"
3+
import debug from "debug"
4+
import report from "gatsby-cli/lib/reporter"
55

6-
module.exports = directory => {
6+
const log = debug(`gatsby:webpack-eslint-config`)
7+
8+
export const hasLocalEslint = (directory: string): boolean => {
79
try {
8-
debug(`Attempting to load package.json for eslint config check`)
10+
log(`Attempting to load package.json for eslint config check`)
911

1012
const pkg = require(path.resolve(directory, `package.json`))
1113
if (pkg.eslintConfig) {
@@ -15,7 +17,7 @@ module.exports = directory => {
1517
report.error(`There was a problem processing the package.json file`, err)
1618
}
1719

18-
debug(`Checking for eslint config file`)
20+
log(`Checking for eslint config file`)
1921
const eslintFiles = glob.sync(`.eslintrc?(.js|.json|.yaml|.yml)`, {
2022
cwd: directory,
2123
})

‎packages/gatsby/src/utils/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const getGatsbyDependents = require(`./gatsby-dependents`)
1414

1515
const apiRunnerNode = require(`./api-runner-node`)
1616
const createUtils = require(`./webpack-utils`)
17-
const hasLocalEslint = require(`./local-eslint-config-finder`)
17+
import { hasLocalEslint } from "./local-eslint-config-finder"
1818

1919
// Four stages or modes:
2020
// 1) develop: for `gatsby develop` command, hot reload and CSS injection into page

0 commit comments

Comments
 (0)
Please sign in to comment.