diff --git a/.vscode/settings.json b/.vscode/settings.json index 6ebc57b1f..71e6bdb8c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,6 @@ "spellright.language": ["fr", "en"], "spellright.documentTypes": ["yaml", "git-commit", "markdown"], "typescript.tsdk": "node_modules/typescript/lib", - "editor.tabSize": 2 + "editor.tabSize": 2, + "eslint.enable": true } diff --git a/mon-entreprise/package.json b/mon-entreprise/package.json index 57cc2534b..d9ec01e57 100644 --- a/mon-entreprise/package.json +++ b/mon-entreprise/package.json @@ -35,7 +35,7 @@ "js-yaml": "^3.13.1", "moo": "^0.5.0", "nearley": "^2.19.0", - "publicodes": "^1.0.0-beta.2", + "publicodes": "^1.0.0-beta.3", "ramda": "^0.27.0", "react": "^16.13.1", "react-color": "^2.14.0", diff --git a/publicodes/package.json b/publicodes/package.json index cff9e84eb..495d93541 100644 --- a/publicodes/package.json +++ b/publicodes/package.json @@ -1,6 +1,6 @@ { "name": "publicodes", - "version": "1.0.0-beta.2", + "version": "1.0.0-beta.3", "description": "A declarative language for encoding public algorithm", "main": "dist/index.js", "types": "dist/types/index.d.ts", @@ -40,7 +40,7 @@ "scripts": { "prepublishOnly": "yarn test && yarn run build", "clean": "rimraf dist node_modules", - "prepare": "rimraf dist && yarn run build", + "prepare": "yarn run rimraf dist && yarn run build", "build": "tsc && yarn run webpack --config webpack.config.js", "test:file": "yarn mocha-webpack --webpack-config ./webpack.test.js --include test/setupIntl.js", "test": "yarn test:file \"./{,!(node_modules)/**/}!(webpack).test.js\"" diff --git a/publicodes/source/components/Modal.tsx b/publicodes/source/components/Modal.tsx index 4d87cd798..14f5f1587 100644 --- a/publicodes/source/components/Modal.tsx +++ b/publicodes/source/components/Modal.tsx @@ -14,6 +14,9 @@ export default function Modal({ ...otherProps }: ModalProps) { useEffect(() => { + if (typeof document === 'undefined') { + return + } const body = document.getElementsByTagName('body')[0] body.classList.add('no-scroll') return () => { diff --git a/publicodes/source/components/PublicodeHighlighter.tsx b/publicodes/source/components/PublicodeHighlighter.tsx index 3f7ac5146..b65f8c5da 100644 --- a/publicodes/source/components/PublicodeHighlighter.tsx +++ b/publicodes/source/components/PublicodeHighlighter.tsx @@ -1,24 +1,35 @@ import React from 'react' import emoji from 'react-easy-emoji' -import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter' -import yaml from 'react-syntax-highlighter/dist/esm/languages/prism/yaml' -import style from 'react-syntax-highlighter/dist/esm/styles/prism/atom-dark' -SyntaxHighlighter.registerLanguage('yaml', yaml) +let Component +if (process.env.NODE_ENV !== 'test') { + const yaml = require('react-syntax-highlighter/dist/esm/languages/prism/yaml') + .default + const style = require('react-syntax-highlighter/dist/esm/styles/prism/atom-dark') + .default + const SyntaxHighlighter = require('react-syntax-highlighter').PrismLight -export default function PublicodeHighlighter({ source }: { source: string }) { - return ( -