Skip to content

Commit cf9c066

Browse files
alviswardpeet
andauthored
fix(gatsby): add this typings to actions (#32210)
avoid unnecessary warnings from @typescript-eslint/unbound-method see https://github.com/typescript-eslint/typescript-eslint/blob/v4.28.0/packages/eslint-plugin/docs/rules/unbound-method.md Co-authored-by: Ward Peeters <[email protected]>
1 parent 53aa88e commit cf9c066

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

packages/gatsby/index.d.ts

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ export interface NodePluginArgs {
931931
* }
932932
* }
933933
*/
934-
loadNodeContent(node: Node): Promise<string>
934+
loadNodeContent(this: void, node: Node): Promise<string>
935935

936936
/**
937937
* Internal redux state used for application state. Do not use, unless you
@@ -953,7 +953,7 @@ export interface NodePluginArgs {
953953
* @example
954954
* const allNodes = getNodes()
955955
*/
956-
getNodes(): Node[]
956+
getNodes(this: void): Node[]
957957

958958
/**
959959
* Get single node by given ID.
@@ -965,7 +965,7 @@ export interface NodePluginArgs {
965965
* @example
966966
* const node = getNode(id)
967967
*/
968-
getNode(id: string): Node
968+
getNode(this: void, id: string): Node
969969

970970
/**
971971
* Get array of nodes of given type.
@@ -975,7 +975,7 @@ export interface NodePluginArgs {
975975
* @example
976976
* const markdownNodes = getNodesByType(`MarkdownRemark`)
977977
*/
978-
getNodesByType(type: string): Node[]
978+
getNodesByType(this: void, type: string): Node[]
979979

980980
/**
981981
* Set of utilities to output information to user
@@ -993,7 +993,7 @@ export interface NodePluginArgs {
993993
* @param path of the node.
994994
* @returns Single node instance.
995995
*/
996-
getNodeAndSavePathDependency(id: string, path: string): Node
996+
getNodeAndSavePathDependency(this: void, id: string, path: string): Node
997997

998998
/**
999999
* Key-value store used to persist results of time/memory/cpu intensive
@@ -1013,7 +1013,7 @@ export interface NodePluginArgs {
10131013
* ...restOfNodeData
10141014
* }
10151015
*/
1016-
createNodeId(input: string): string
1016+
createNodeId(this: void, input: string): string
10171017

10181018
/**
10191019
* Create a stable content digest from a string or object, you can use the
@@ -1031,7 +1031,7 @@ export interface NodePluginArgs {
10311031
* }
10321032
* }
10331033
*/
1034-
createContentDigest(input: string | object): string
1034+
createContentDigest(this: void, input: string | object): string
10351035

10361036
/**
10371037
* Set of utilities that allow adding more detailed tracing for plugins.
@@ -1070,10 +1070,11 @@ export interface BuildArgs extends ParentSpanPluginArgs {
10701070

10711071
export interface Actions {
10721072
/** @see https://www.gatsbyjs.org/docs/actions/#deletePage */
1073-
deletePage(args: { path: string; component: string }): void
1073+
deletePage(this: void, args: { path: string; component: string }): void
10741074

10751075
/** @see https://www.gatsbyjs.org/docs/actions/#createPage */
10761076
createPage<TContext = Record<string, unknown>>(
1077+
this: void,
10771078
args: Page<TContext>,
10781079
plugin?: ActionPlugin,
10791080
option?: ActionOptions
@@ -1084,6 +1085,7 @@ export interface Actions {
10841085

10851086
/** @see https://www.gatsbyjs.org/docs/actions/#createNode */
10861087
createNode<TNode = Record<string, unknown>>(
1088+
this: void,
10871089
node: NodeInput & TNode,
10881090
plugin?: ActionPlugin,
10891091
options?: ActionOptions
@@ -1094,6 +1096,7 @@ export interface Actions {
10941096

10951097
/** @see https://www.gatsbyjs.org/docs/actions/#createNodeField */
10961098
createNodeField(
1099+
this: void,
10971100
args: {
10981101
node: Node
10991102
name?: string
@@ -1105,39 +1108,44 @@ export interface Actions {
11051108

11061109
/** @see https://www.gatsbyjs.org/docs/actions/#createParentChildLink */
11071110
createParentChildLink(
1111+
this: void,
11081112
args: { parent: Node; child: NodeInput },
11091113
plugin?: ActionPlugin
11101114
): void
11111115

11121116
/** @see https://www.gatsbyjs.org/docs/actions/#setWebpackConfig */
1113-
setWebpackConfig(config: object, plugin?: ActionPlugin): void
1117+
setWebpackConfig(this: void, config: object, plugin?: ActionPlugin): void
11141118

11151119
/** @see https://www.gatsbyjs.org/docs/actions/#replaceWebpackConfig */
1116-
replaceWebpackConfig(config: object, plugin?: ActionPlugin): void
1120+
replaceWebpackConfig(this: void, config: object, plugin?: ActionPlugin): void
11171121

11181122
/** @see https://www.gatsbyjs.org/docs/actions/#setBabelOptions */
1119-
setBabelOptions(options: object, plugin?: ActionPlugin): void
1123+
setBabelOptions(this: void, options: object, plugin?: ActionPlugin): void
11201124

11211125
/** @see https://www.gatsbyjs.org/docs/actions/#setBabelPlugin */
11221126
setBabelPlugin(
1127+
this: void,
11231128
config: { name: string; options: object },
11241129
plugin?: ActionPlugin
11251130
): void
11261131

11271132
/** @see https://www.gatsbyjs.org/docs/actions/#setBabelPreset */
11281133
setBabelPreset(
1134+
this: void,
11291135
config: { name: string; options: object },
11301136
plugin?: ActionPlugin
11311137
): void
11321138

11331139
/** @see https://www.gatsbyjs.org/docs/actions/#createJob */
11341140
createJob(
1141+
this: void,
11351142
job: Record<string, unknown> & { id: string },
11361143
plugin?: ActionPlugin
11371144
): void
11381145

11391146
/** @see https://www.gatsbyjs.org/docs/actions/#createJobV2 */
11401147
createJobV2(
1148+
this: void,
11411149
job: {
11421150
name: string
11431151
inputPaths: string[]
@@ -1149,18 +1157,24 @@ export interface Actions {
11491157

11501158
/** @see https://www.gatsbyjs.org/docs/actions/#setJob */
11511159
setJob(
1160+
this: void,
11521161
job: Record<string, unknown> & { id: string },
11531162
plugin?: ActionPlugin
11541163
): void
11551164

11561165
/** @see https://www.gatsbyjs.org/docs/actions/#endJob */
1157-
endJob(job: { id: string }, plugin?: ActionPlugin): void
1166+
endJob(this: void, job: { id: string }, plugin?: ActionPlugin): void
11581167

11591168
/** @see https://www.gatsbyjs.org/docs/actions/#setPluginStatus */
1160-
setPluginStatus(status: Record<string, unknown>, plugin?: ActionPlugin): void
1169+
setPluginStatus(
1170+
this: void,
1171+
status: Record<string, unknown>,
1172+
plugin?: ActionPlugin,
1173+
): void;
11611174

11621175
/** @see https://www.gatsbyjs.org/docs/actions/#createRedirect */
11631176
createRedirect(
1177+
this: void,
11641178
redirect: {
11651179
fromPath: string
11661180
isPermanent?: boolean
@@ -1176,13 +1190,15 @@ export interface Actions {
11761190

11771191
/** @see https://www.gatsbyjs.org/docs/actions/#addThirdPartySchema */
11781192
addThirdPartySchema(
1193+
this: void,
11791194
args: { schema: object },
11801195
plugin?: ActionPlugin,
11811196
traceId?: string
11821197
): void
11831198

11841199
/** @see https://www.gatsbyjs.org/docs/actions/#createTypes */
11851200
createTypes(
1201+
this: void,
11861202
types:
11871203
| string
11881204
| GraphQLOutputType
@@ -1196,12 +1212,14 @@ export interface Actions {
11961212

11971213
/** @see https://www.gatsbyjs.org/docs/actions/#createFieldExtension */
11981214
createFieldExtension(
1215+
this: void,
11991216
extension: object,
12001217
plugin?: ActionPlugin,
12011218
traceId?: string
12021219
): void
12031220

12041221
printTypeDefinitions(
1222+
this: void,
12051223
path?: string,
12061224
include?: { types?: Array<string>; plugins?: Array<string> },
12071225
exclude?: { types?: Array<string>; plugins?: Array<string> },

0 commit comments

Comments
 (0)