Skip to content

Commit 68a01e7

Browse files
DanielRufwardpeet
authored andcommitted
chore(eslint): remove unused expressions (#11041)
* Enable no-unused-expressions ESLint rule * Fix experimentalObjectRestSpread deprecation error
1 parent 7836a84 commit 68a01e7

File tree

11 files changed

+35
-19
lines changed

11 files changed

+35
-19
lines changed

.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
"as-needed",
3535
{ "requireReturnForObjectLiteral": true }
3636
],
37+
"no-unused-expressions": [
38+
"error",
39+
{
40+
"allowTaggedTemplates": true
41+
}
42+
],
3743
"consistent-return": ["error"],
3844
"no-console": "off",
3945
"no-inner-declarations": "off",

e2e-tests/production-runtime/scripts/chunks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const restore = () => {
122122

123123
console.log(`Restored resources`)
124124
}
125-
125+
// eslint-disable-next-line no-unused-expressions
126126
yargs
127127
.command(
128128
`block <chunk>`,

packages/gatsby-image/src/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ class Image extends React.Component {
208208
if (this.state.seenBefore) {
209209
this.setState({ fadeIn: false })
210210
}
211-
this.props.onLoad && this.props.onLoad()
211+
212+
if (this.props.onLoad) {
213+
this.props.onLoad()
214+
}
212215
}
213216

214217
render() {

packages/gatsby-link/src/index.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ class GatsbyLink extends React.Component {
6666
}
6767

6868
handleRef(ref) {
69-
this.props.innerRef && this.props.innerRef(ref)
69+
if (this.props.innerRef) {
70+
this.props.innerRef(ref)
71+
}
7072

7173
if (this.state.IOSupported && ref) {
7274
// If IO supported and element reference found, setup Observer functionality
@@ -120,13 +122,15 @@ class GatsbyLink extends React.Component {
120122
getProps={getProps}
121123
innerRef={this.handleRef}
122124
onMouseEnter={e => {
123-
// eslint-disable-line
124-
onMouseEnter && onMouseEnter(e)
125+
if (onMouseEnter) {
126+
onMouseEnter(e)
127+
}
125128
___loader.hovering(parsePath(to).pathname)
126129
}}
127130
onClick={e => {
128-
// eslint-disable-line
129-
onClick && onClick(e)
131+
if (onClick) {
132+
onClick(e)
133+
}
130134

131135
if (
132136
e.button === 0 && // ignore right clicks

packages/gatsby-plugin-jss/src/gatsby-browser.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ const ThemeProvider = require(`react-jss`).ThemeProvider
44
// remove the JSS style tag generated on the server to avoid conflicts with the one added on the client
55
exports.onInitialClientRender = () => {
66
const ssStyles = window.document.getElementById(`server-side-jss`)
7-
ssStyles && ssStyles.parentNode.removeChild(ssStyles)
7+
if (ssStyles) {
8+
ssStyles.parentNode.removeChild(ssStyles)
9+
}
810
}
911
// eslint-disable-next-line react/prop-types
1012
exports.wrapRootElement = ({ element }, options) => {

packages/gatsby-plugin-react-css-modules/src/gatsby-node.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
exports.onCreateBabelConfig = ({ actions }, pluginOptions) => {
22
const isDevelopment = process.env.NODE_ENV !== `production`
33

4-
pluginOptions.plugins && delete pluginOptions.plugins
4+
if (pluginOptions.plugins) {
5+
delete pluginOptions.plugins
6+
}
57

68
actions.setBabelPlugin({
79
name: `babel-plugin-react-css-modules`,

packages/gatsby-remark-prismjs/src/highlight-code.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ module.exports = (language, code, lineNumbersHighlight = []) => {
3030
// Don't add back the new line character after highlighted lines
3131
// as they need to be display: block and full-width.
3232
codeSplits.forEach((split, idx) => {
33-
split.highlight
34-
? (finalCode += split.code)
35-
: (finalCode += `${split.code}${idx == lastIdx ? `` : `\n`}`)
33+
finalCode += split.highlight
34+
? split.code
35+
: `${split.code}${idx == lastIdx ? `` : `\n`}`
3636
})
3737

3838
return finalCode

packages/gatsby-source-contentful/src/gatsby-node.js

-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ exports.sourceNodes = async (
165165

166166
// Update existing entry nodes that weren't updated but that need reverse
167167
// links added.
168-
Object.keys(foreignReferenceMap)
169168
existingNodes
170169
.filter(n => _.includes(newOrUpdatedEntries, n.id))
171170
.forEach(n => {

packages/gatsby-source-shopify/src/lib.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ export const queryAll = async (
4747
const edges = get([...path, `edges`], data)
4848
const nodes = edges.map(edge => edge.node)
4949

50-
aggregatedResponse
51-
? (aggregatedResponse = aggregatedResponse.concat(nodes))
52-
: (aggregatedResponse = nodes)
50+
aggregatedResponse = aggregatedResponse
51+
? aggregatedResponse.concat(nodes)
52+
: nodes
5353

5454
if (get([...path, `pageInfo`, `hasNextPage`], false, data))
5555
return queryAll(

packages/gatsby/src/utils/websocket-manager.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ class WebsocketManager {
103103
this.pageResults = new Map()
104104
this.staticQueryResults = new Map()
105105
this.errors = new Map()
106-
this.websocket
107-
this.programDir
106+
// this.websocket
107+
// this.programDir
108108

109109
this.init = this.init.bind(this)
110110
this.getSocket = this.getSocket.bind(this)

starters/blog/.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
"parserOptions": {
1313
"sourceType": "module",
1414
"ecmaFeatures": {
15-
"experimentalObjectRestSpread": true,
15+
"ecmaVersion": 2018,
1616
"jsx": true,
1717
},
1818
}

0 commit comments

Comments
 (0)