Unexpected token and octokit deprecation error
See original GitHub issueI’m running a simple example dangerfile.js straight from the docs, using the latest 7.0.2:
import { message, danger } from 'danger';
import { readFileSync } from 'fs';
const modifiedMD = danger.git.modified_files.join('- ');
message(`Changed Files in this PR: \n - ${modifiedMD}`);
and yarn danger local
throws both syntax error and deprecation notice:
> yarn danger local
yarn run v1.13.0
$ <user>/node_modules/.bin/danger local
Error: new Octokit({headers}) is deprecated. Use {userAgent, previews} instead. See https://github.com/octokit/rest.js#client-options
at parseOptions (<user>/node_modules/@octokit/rest/lib/parse-client-options.js:43:18)
at new Octokit (<user>/node_modules/@octokit/rest/lib/constructor.js:14:50)
at apiForDSL (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:114:15)
at Object.<anonymous> (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:72:23)
at step (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:43:23)
at Object.next (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:24:53)
at <user>/node_modules/danger/distribution/runner/jsonToDSL.js:18:71
at new Promise (<anonymous>)
at __awaiter (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:14:12)
at Object.exports.jsonToDSL (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:65:53)
Error: octokit.authenticate() is deprecated. Use "auth" constructor option instead.
at authenticate (<user>/node_modules/@octokit/rest/plugins/authentication-deprecated/authenticate.js:4:16)
at apiForDSL (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:116:13)
at Object.<anonymous> (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:72:23)
at step (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:43:23)
at Object.next (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:24:53)
at <user>/node_modules/danger/distribution/runner/jsonToDSL.js:18:71
at new Promise (<anonymous>)
at __awaiter (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:14:12)
at Object.exports.jsonToDSL (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:65:53)
at Object.<anonymous> (<user>/node_modules/danger/distribution/runner/jsonToContext.js:55:54)
Unable to evaluate the Dangerfile
dangerfile.js:14
import { readFileSync } from 'fs';
^
SyntaxError: Unexpected token {
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.requireFromString [as default] (<user>/node_modules/require-from-string/index.js:28:4)
at Object.<anonymous> (<user>/node_modules/danger/distribution/runner/runners/inline.js:144:63)
at step (<user>/node_modules/danger/distribution/runner/runners/inline.js:32:23)
at Object.next (<user>/node_modules/danger/distribution/runner/runners/inline.js:13:53)
at <user>/node_modules/danger/distribution/runner/runners/inline.js:7:71
at new Promise (<anonymous>)
Error: new Octokit({headers}) is deprecated. Use {userAgent, previews} instead. See https://github.com/octokit/rest.js#client-options
at parseOptions (<user>/node_modules/@octokit/rest/lib/parse-client-options.js:43:18)
at new Octokit (<user>/node_modules/@octokit/rest/lib/constructor.js:14:50)
at apiForDSL (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:114:15)
at Object.<anonymous> (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:72:23)
at step (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:43:23)
at Object.next (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:24:53)
at <user>/node_modules/danger/distribution/runner/jsonToDSL.js:18:71
at new Promise (<anonymous>)
at __awaiter (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:14:12)
at Object.exports.jsonToDSL (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:65:53)
Error: octokit.authenticate() is deprecated. Use "auth" constructor option instead.
at authenticate (<user>/node_modules/@octokit/rest/plugins/authentication-deprecated/authenticate.js:4:16)
at apiForDSL (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:116:13)
at Object.<anonymous> (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:72:23)
at step (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:43:23)
at Object.next (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:24:53)
at <user>/node_modules/danger/distribution/runner/jsonToDSL.js:18:71
at new Promise (<anonymous>)
at __awaiter (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:14:12)
at Object.exports.jsonToDSL (<user>/node_modules/danger/distribution/runner/jsonToDSL.js:65:53)
at Object.<anonymous> (<user>/node_modules/danger/distribution/commands/utils/runDangerSubprocess.js:159:54)
Danger: ⅹ Failing the build, there is 1 fail.
## Failures
Danger failed to run `dangerfile.js`.
## Markdowns
## Error SyntaxError
Unexpected token {
dangerfile.js:14
import { readFileSync } from 'fs';
^
SyntaxError: Unexpected token {
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.requireFromString [as default] (<user>/node_modules/require-from-string/index.js:28:4)
at Object.<anonymous> (<user>/node_modules/danger/distribution/runner/runners/inline.js:144:63)
at step (<user>/node_modules/danger/distribution/runner/runners/inline.js:32:23)
at Object.next (<user>/node_modules/danger/distribution/runner/runners/inline.js:13:53)
at <user>/node_modules/danger/distribution/runner/runners/inline.js:7:71
at new Promise (<anonymous>)
### Dangerfile
---------^
Am I missing something?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:8 (3 by maintainers)
Top Results From Across the Web
ESLint Parsing error: Unexpected token - Stack Overflow
Unexpected token errors in ESLint parsing occur due to incompatibility between your development environment and ESLint's current parsing ...
Read more >Build error with @arcgis/core and Angular 11: "Module parse ...
Just chiming in, am getting similar "unexpected token" errors after bumping to v4.24. Had been pinned at v4.22 due to changes to the...
Read more >How to validate your GraphQL queries with ESLint
To make my queries, I decided to use @octokit/graphql, ... graphql/no-deprecated-fields: error # disallows use of deprecated fields ...
Read more >unexpected end of json input at json.parse (<anonymous>)
Then more errors, including "Unexpected token d " or similar: Stratum Error SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at ...
Read more >danger - Bountysource
Unexpected token and octokit deprecation error $ 0. Created 3 years ago in danger/danger-js with 8 comments. I'm running a simple example dangerfile.js ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It seems after working with @kangax on this that regular node module imports work fine (like ‘lodash’, and ‘danger’), but native imports like fs and path, it seems as though you have to use
require('module')
and not useimport module from 'module'
as then you hot the error that @kangax had.I will try to look into the danger code to see if there is anything I can do for a PR to fix this issue
@orta Thanks! The relevant output seems to be:
so it finds config but then ignores it?
Full output