diff --git a/libraries/codemirror/addon/lint/eslint.js b/libraries/codemirror/addon/lint/eslint.js deleted file mode 100644 index ce6e226a7..000000000 --- a/libraries/codemirror/addon/lint/eslint.js +++ /dev/null @@ -1,98 +0,0 @@ -// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE - -(function(mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - mod(require("../../lib/codemirror")); - else if (typeof define == "function" && define.amd) // AMD - define(["../../lib/codemirror"], mod); - else // Plain browser env - mod(CodeMirror); -})(function(CodeMirror) { - "use strict"; - - async function validatorHtml(text, options) { - const result = /]*>([\s\S]+)<\/script>/ig.exec(text); - - if (result !== null) { - // preceding code is copied over but any (non-newline) character is replaced with space - // this will preserve line numbers etc. - const prefix = text.substr(0, result.index).replace(/./g, " "); - - const js = prefix + result[1]; - - return await validatorJavaScript(js, options); - } - - return []; - } - - async function validatorJavaScript(text, options) { - if (glob.isMobile() - || glob.getActiveContextNote() == null - || glob.getActiveContextNote().mime === 'application/json') { - // eslint doesn't seem to validate pure JSON well - return []; - } - - await glob.requireLibrary(glob.ESLINT); - - if (text.length > 20000) { - console.log("Skipping linting because of large size: ", text.length); - - return []; - } - - const errors = new eslint().verify(text, { - root: true, - parserOptions: { - ecmaVersion: "latest" - }, - extends: ['eslint:recommended', 'airbnb-base'], - env: { - 'browser': true, - 'node': true - }, - rules: { - 'import/no-unresolved': 'off', - 'func-names': 'off', - 'comma-dangle': ['warn'], - 'padded-blocks': 'off', - 'linebreak-style': 'off', - 'class-methods-use-this': 'off', - 'no-unused-vars': ['warn', { vars: 'local', args: 'after-used' }], - 'no-nested-ternary': 'off', - 'no-underscore-dangle': ['error', {'allow': ['_super', '_lookupFactory']}] - }, - globals: { - "api": "readonly" - } - }); - - const result = []; - if (errors) { - parseErrors(errors, result); - } - - return result; - } - - CodeMirror.registerHelper("lint", "javascript", validatorJavaScript); - CodeMirror.registerHelper("lint", "html", validatorHtml); - - function parseErrors(errors, output) { - for (const error of errors) { - const startLine = error.line - 1; - const endLine = error.endLine !== undefined ? error.endLine - 1 : startLine; - const startCol = error.column - 1; - const endCol = error.endColumn !== undefined ? error.endColumn - 1 : startCol + 1; - - output.push({ - message: error.message, - severity: error.severity === 1 ? "warning" : "error", - from: CodeMirror.Pos(startLine, startCol), - to: CodeMirror.Pos(endLine, endCol) - }); - } - } -}); diff --git a/src/public/app/services/library_loader.js b/src/public/app/services/library_loader.js index 7aba0eb38..d1935fe0a 100644 --- a/src/public/app/services/library_loader.js +++ b/src/public/app/services/library_loader.js @@ -8,7 +8,6 @@ const CODE_MIRROR = { "libraries/codemirror/addon/edit/matchtags.js", "libraries/codemirror/addon/fold/xml-fold.js", "libraries/codemirror/addon/lint/lint.js", - "libraries/codemirror/addon/lint/eslint.js", "libraries/codemirror/addon/mode/loadmode.js", "libraries/codemirror/addon/mode/multiplex.js", "libraries/codemirror/addon/mode/overlay.js", diff --git a/src/routes/assets.ts b/src/routes/assets.ts index ddadc9af9..c6f1e7c48 100644 --- a/src/routes/assets.ts +++ b/src/routes/assets.ts @@ -70,6 +70,7 @@ function register(app: express.Application) { app.use(`/${assetPath}/node_modules/split.js/dist/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/split.js/dist/'))); app.use(`/${assetPath}/node_modules/panzoom/dist/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/panzoom/dist/'))); + // i18n app.use(`/${assetPath}/node_modules/i18next/`, persistentCacheStatic(path.join(srcRoot, "..", 'node_modules/i18next/'))); app.use(`/${assetPath}/node_modules/i18next-http-backend/`, persistentCacheStatic(path.join(srcRoot, "..", 'node_modules/i18next-http-backend/')));