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

[v2] fix eslint warnings #5121

Merged
merged 3 commits into from
Apr 25, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions packages/gatsby-source-contentful/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ exports.buildForeignReferenceMap = ({
return foreignReferenceMap
}

function createTextNode(node, key, text, createNode, createNodeId) {
function prepareTextNode(node, key, text, createNode, createNodeId) {
const str = _.isString(text) ? text : ` `
const textNode = {
id: createNodeId(`${node.id}${key}TextNode`),
Expand All @@ -169,7 +169,7 @@ function createTextNode(node, key, text, createNode, createNodeId) {
return textNode
}

function createJSONNode(node, key, content, createNode, createNodeId) {
function prepareJSONNode(node, key, content, createNode, createNodeId) {
const str = JSON.stringify(content)
const JSONNode = {
...content,
Expand Down
2 changes: 0 additions & 2 deletions packages/gatsby-source-filesystem/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ const fsMachine = Machine({

let currentState = fsMachine.initialState

const fileQueue = new Map()

exports.sourceNodes = (
{ actions, getNode, createNodeId, hasNodeChanged, reporter, emitter },
pluginOptions
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-source-wordpress/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.sourceNodes = async (
excludedRoutes = [],
}
) => {
const { createNode } = actions
const { createNode, touchNode } = actions
_verbose = verboseOutput
_siteURL = `${protocol}://${baseUrl}`
_useACF = useACF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const traverse = require(`babel-traverse`).default

async function onCreateNode({ node, getNode, actions, loadNodeContent }) {
const { createNode, createParentChildLink } = actions
const fileExtsToProcess = [`js`, `jsx`, `ts`, `tsx`]

// This only processes javascript and typescript files.
if (!_.includes(fileExtsToProcess, node.extension)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async function parseToAst(filePath, fileStr) {
`There was a problem parsing "${filePath}"; any GraphQL ` +
`fragments or queries in this file were not processed. \n` +
`This may indicate a syntax error in the code, or it may be a file type ` +
`That Gatsby does not know how to parse.`
`that Gatsby does not know how to parse.`
)
}
}
Expand All @@ -108,7 +108,6 @@ async function findGraphQLTags(file, text): Promise<Array<DefinitionNode>> {
parseToAst(file, text)
.then(ast => {
let queries = []
let isStaticQuery = false
if (!ast) {
resolve(queries)
return
Expand All @@ -119,11 +118,13 @@ async function findGraphQLTags(file, text): Promise<Array<DefinitionNode>> {
TaggedTemplateExpression(path) {
if (
(`descendant of query`,
// eslint-disable-next-line no-undef
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't figure out how to get babel-eslint to like the optional chaining here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, noticed that too — it must not be setup to use or repo babel setup

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one specific minor version that it works with...I'll find it I have it set in another project but don't remember off the top of my head :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that'd be ace, thanks :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its 8.2.1 and earlier i think, you can pin to that specific version tho, any higher and it's broken. babel/babel-eslint#595

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks!

path?.parentPath?.parentPath?.node?.name?.name !== `query`)
) {
return
}
if (
// eslint-disable-next-line no-undef
path.parentPath?.parentPath?.parentPath?.node?.name?.name !==
`StaticQuery`
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ module.exports = async (queryJob: QueryJob, component: Any) => {
Errors:
${result.errors || []}
URL path:
${pageOrLayout.path}
${queryJob.path}
Plugin:
${pageOrLayout.pluginCreatorId || `none`}
${queryJob.pluginCreatorId || `none`}
Query:
${component.query}
`
Expand All @@ -63,6 +63,7 @@ module.exports = async (queryJob: QueryJob, component: Any) => {
}

// Add the page context onto the results.
// eslint-disable-next-line no-undef
if (queryJob?.isPage) {
result[`pageContext`] = queryJob.context
}
Expand All @@ -78,6 +79,7 @@ module.exports = async (queryJob: QueryJob, component: Any) => {
.replace(/[^a-zA-Z0-9-_]/g, ``)

let dataPath
// eslint-disable-next-line no-undef
if (queryJob?.isPage) {
dataPath = `${generatePathChunkName(queryJob.jsonName)}-${resultHash}`
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const writeRedirects = async () => {

lastHash = newHash

await fs.writeFile(
return await fs.writeFile(
joinPath(program.directory, `.cache/redirects.json`),
JSON.stringify(browserRedirects, null, 2)
)
Expand Down
8 changes: 0 additions & 8 deletions packages/gatsby/src/redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ const _ = require(`lodash`)
const { bindActionCreators } = require(`redux`)
const { stripIndent } = require(`common-tags`)
const report = require(`gatsby-cli/lib/reporter`)
const glob = require(`glob`)
const path = require(`path`)
const fs = require(`fs`)
const { joinPath } = require(`../utils/path`)
const { hasNodeChanged, getNode } = require(`./index`)
const { trackInlineObjectsInRootNode } = require(`../schema/node-tracking`)
const { store } = require(`./index`)
Expand Down Expand Up @@ -347,12 +345,6 @@ actions.deleteNodes = (nodes: any[], plugin: Plugin) => {
plugin,
payload: nodes,
}

if (deleteDescendantsActions) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this as eslint marked it as unreachable. Should deleting descendants still be included?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah — this might be a bad merge. If you look at deleteNode, it finds descendant nodes to delete above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted this, handling it in #5106 instead.

return [...deleteDescendantsActions, deleteNodesAction]
} else {
return deleteNodesAction
}
}

const typeOwners = {}
Expand Down