Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script
See original GitHub issueI just installed prettier@1.4 (which supports typescript formatting) in my local project, added .ts
onto list of files that prettier should run on, and saved a typescript file. I got the following output:
EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".
Hide Stack Trace
EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".
at Object.parse (/Users/murphy/projects/dayone/DayOne-Web/prj-app/node_modules/prettier/index.js:12058:21)
at formatWithCursor (/Users/murphy/projects/dayone/DayOne-Web/prj-app/node_modules/prettier/index.js:12267:22)
at format (/Users/murphy/projects/dayone/DayOne-Web/prj-app/node_modules/prettier/index.js:12307:10)
at formatWithShebang (/Users/murphy/projects/dayone/DayOne-Web/prj-app/node_modules/prettier/index.js:12465:12)
at Object.format (/Users/murphy/projects/dayone/DayOne-Web/prj-app/node_modules/prettier/index.js:12481:12)
at executePrettier (/Users/murphy/.atom/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:18:38)
at executePrettierOrPrettierEslint (/Users/murphy/.atom/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:29:70)
at executePrettierOnBufferRange (/Users/murphy/.atom/packages/prettier-atom/dist/executePrettier/executePrettierOnBufferRange.js:38:21)
at formatOnSaveIfAppropriate (/Users/murphy/.atom/packages/prettier-atom/dist/formatOnSave/index.js:14:122)
at lazyFormatOnSave (/Users/murphy/.atom/packages/prettier-atom/dist/main.js:40:15)
at /Users/murphy/.atom/packages/prettier-atom/dist/main.js:101:14
at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:25:20)
at Emitter.module.exports.Emitter.emit (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:141:34)
at TextBuffer.module.exports.TextBuffer.saveAs (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:1119:26)
at TextBuffer.module.exports.TextBuffer.save (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:1108:25)
at TextEditor.module.exports.TextEditor.save (/Applications/Atom Beta.app/Contents/Resources/app/src/text-editor.js:925:32)
at Pane.module.exports.Pane.saveItem (/Applications/Atom Beta.app/Contents/Resources/app/src/pane.js:780:24)
at Pane.saveItem (/Applications/Atom Beta.app/Contents/Resources/app/src/pane.js:3:65)
at Pane.module.exports.Pane.saveActiveItem (/Applications/Atom Beta.app/Contents/Resources/app/src/pane.js:763:25)
at Workspace.saveActivePaneItem (/Applications/Atom Beta.app/Contents/Resources/app/src/workspace.js:1503:46)
at atom-workspace.core:save (/Applications/Atom Beta.app/Contents/Resources/app/src/register-default-commands.js:236:38)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom Beta.app/Contents/Resources/app/src/command-registry.js:265:35)
at /Applications/Atom Beta.app/Contents/Resources/app/src/command-registry.js:3:65
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:610:22)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:401:28)
at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom Beta.app/Contents/Resources/app/src/window-event-handler.js:100:42)
at HTMLDocument.<anonymous> (/Applications/Atom Beta.app/Contents/Resources/app/src/window-event-handler.js:3:65)
Prettier:Debug output:
Atom version: 1.18.0-beta2 prettier-atom version: 0.31.1 prettier version: 1.3.1 prettier-eslint version: 6.2.2 prettier-atom configuration: { "formatOnSave": true, "formatOnSaveOptions": { "enabled": true, "scopes": [ "source.js", "source.ts" ], "showInStatusBar": true, "respectEslintignore": true, "excludedGlobs": [], "whitelistedGlobs": [] }, "prettierOptions": { "parser": "flow", "singleQuote": false, "bracketSpacing": true, "semi": true, "useTabs": false, "jsxBracketSameLine": false, "printWidth": 80, "tabWidth": "auto", "trailingComma": "none" }, "silenceErrors": false, "useEslint": false, "useEditorConfig": true, "prettierEslintOptions": { "prettierLast": false } }
Issue Analytics
- State:
- Created 6 years ago
- Reactions:13
- Comments:5
Top Results From Across the Web
Chrome extension compiled by Webpack throws `unsafe-eval ...
Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security ......
Read more >Refused to evaluate a string as JavaScript because ... - GitHub
Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content ...
Read more >ERROR EvalError: Refused to evaluate a string as JavaScript ...
EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content ...
Read more >unsafe-eval is not an allowed source of script in the following ...
Refused to evaluate a string as JavaScript because unsafe -eval is not an allowed source of script in the following Content Security Policy...
Read more >Chrome: script-src eval: Refused to evaluate a string as ...
Solution: Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content ......
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
Okay 1.4.1 was just released, and I’ve verified that this solves the problem!
Answering my own question dropping prettier to “prettier”: “1.31.1”, works for now with prettier-atom 0.31.1