You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
return`console.log('The UN Secretary-General is ${secretaryGeneral}')`
218
220
})
219
221
returnresult
@@ -225,37 +227,13 @@ console.log('The UN Secretary-General is António Guterres')
225
227
// codegen:end
226
228
```
227
229
228
-
It will not re-run unless the input has changed, the output hash doesn't match, or until 1 year after the recorded timestamp. "The input" is a hash of the following:
230
+
Since hitting wikipedia servers is slow and unreliable, you don't want to do it every time you lint. The codegen will be a no-op and leave the content untouched unless:
229
231
230
-
-the filename the directive appears in
231
-
- the source code _excluding_ any existing content between the `codegen:start` and `codegen:end` directives
232
-
- the options passed to the preset
232
+
-4 weeks has passed since the `timestamp`
233
+
- the output hash doesn't match the generated content (this can happen if someone manually changes the generated content)
234
+
- the input hash doesn't match the values passed to the preset
233
235
234
-
The output (i.e. the generated code between the start and end directives) is also hashed and written to the hash directive.
235
-
236
-
If the the generated code doesn't match the output hash, the generator function will re-run.
237
-
238
-
This means that if you change the filename, or any of the source code, it will re-run. You can control this behaviour when defining your generator function:
console.log('The UN Secretary-General is António Guterres')
257
-
// codegen:end
258
-
```
236
+
Note that in the example above, we are using `cheerio` without having to import it - you don't even need it installed in your devDependencies (it's a dependency of eslint-plugin-codegen - so it does live in your node_modules, you just don't need to manage it or worry about tree-shaking).
259
237
260
238
The helpers that are provided to the generator function via the `dependencies` prop are listed below. You can use all of them in a type-safe way in your generator function, without having to add them as dependencies or even devDependencies:
0 commit comments