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): Convert local-eslint-config-finder to typescript #22403

Merged
merged 1 commit into from
Mar 19, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
const { store } = require(`../redux`)
const eslintConfig = require(`./eslint-config`)
const hasLocalEslint = require(`./local-eslint-config-finder`)
const { hasLocalEslint } = require(`./local-eslint-config-finder`)

const isEslintRule = rule => {
const options = rule && rule.use && rule.use[0] && rule.use[0].options
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const path = require(`path`)
const glob = require(`glob`)
const debug = require(`debug`)(`gatsby:webpack-eslint-config`)
const report = require(`gatsby-cli/lib/reporter`)
import path from "path"
import glob from "glob"
import debug from "debug"
import report from "gatsby-cli/lib/reporter"

module.exports = directory => {
const log = debug(`gatsby:webpack-eslint-config`)

export const hasLocalEslint = (directory: string): boolean => {
try {
debug(`Attempting to load package.json for eslint config check`)
log(`Attempting to load package.json for eslint config check`)

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

debug(`Checking for eslint config file`)
log(`Checking for eslint config file`)
const eslintFiles = glob.sync(`.eslintrc?(.js|.json|.yaml|.yml)`, {
cwd: directory,
})
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/utils/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getGatsbyDependents = require(`./gatsby-dependents`)

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

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