From 6ddf872dece46773fd2da47e97f97a1865b3a2fa Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Fri, 16 Aug 2019 09:37:09 +0800 Subject: [PATCH 1/6] Initial support for markdownlint Signed-off-by: Yukai Huang --- package.json | 1 + public/images/lint/mark-error.png | Bin 0 -> 193 bytes public/images/lint/mark-multiple.png | Bin 0 -> 126 bytes public/images/lint/mark-warning.png | Bin 0 -> 215 bytes public/images/lint/message-error.png | Bin 0 -> 194 bytes public/images/lint/message-warning.png | Bin 0 -> 233 bytes public/js/lib/editor/index.js | 5 +- public/js/lib/editor/markdown-lint/index.js | 42 ++++++++++++ public/js/lib/editor/markdown-lint/lint.css | 72 ++++++++++++++++++++ public/js/url.js | 1 + webpack.common.js | 9 ++- yarn.lock | 9 ++- 12 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 public/images/lint/mark-error.png create mode 100644 public/images/lint/mark-multiple.png create mode 100644 public/images/lint/mark-warning.png create mode 100644 public/images/lint/message-error.png create mode 100644 public/images/lint/message-warning.png create mode 100644 public/js/lib/editor/markdown-lint/index.js create mode 100644 public/js/lib/editor/markdown-lint/lint.css create mode 100644 public/js/url.js diff --git a/package.json b/package.json index 45857e99..1c470b2c 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "markdown-it-sub": "~1.0.0", "markdown-it-sup": "~1.0.0", "markdown-pdf": "~9.0.0", + "markdownlint": "^0.16.0", "mathjax": "~2.7.5", "mattermost-redux": "~5.13.0", "mermaid": "~8.2.3", diff --git a/public/images/lint/mark-error.png b/public/images/lint/mark-error.png new file mode 100644 index 0000000000000000000000000000000000000000..045901dab016b239fed74449dad9155496a21a75 GIT binary patch literal 193 zcmeAS@N?(olHy`uVBq!ia0vp^EI`c6!3HF^d|7u4NHG=%xjQkeJ16rJ$YD$Jc6VX; z4}uH!E}sk(;VkfoEM{Qf76xHPhFNnYfP(BLp1!W^w>kOwWGqy-{#gVRk}PqJC~?lu z%}vcKVQ?-=O)N=GQ7F$W$xv|j^bH7a literal 0 HcmV?d00001 diff --git a/public/images/lint/mark-multiple.png b/public/images/lint/mark-multiple.png new file mode 100644 index 0000000000000000000000000000000000000000..8af299b6569c4f3e075688177295594251677264 GIT binary patch literal 126 zcmeAS@N?(olHy`uVBq!ia0vp^>>$j+3?x7IEPn{3I0Jk_T!AzY?BBn?^pQ_Hki}RM zvd$@?2>?C~A&US2 literal 0 HcmV?d00001 diff --git a/public/images/lint/mark-warning.png b/public/images/lint/mark-warning.png new file mode 100644 index 0000000000000000000000000000000000000000..d7f28bf6650281eb33c1e29cc425a5e22c3ed627 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^EI`c6!3HF^d|7u4NHG=%xjQkeJ16rJ$YD$Jc6VX; z4}uH!E}sk(;VkfoEM{Qf76xHPhFNnYfP(BLp1!W^w>iZ`#07T*H*W(9NtU=qlsM<- z=BDPAFgO>bCYGe8D3oWGWGJ|M`UZqI@`(c#8F{)mhHzX@PHAY;S1%DaGB7AHuCrVy zed@r02Zs+FxN!EsfejrGPjlWaj`w@<${|#ekwHU%cU#+=373Jo89ZJ6T-G@yGywp& CIYKW0 literal 0 HcmV?d00001 diff --git a/public/images/lint/message-error.png b/public/images/lint/message-error.png new file mode 100644 index 0000000000000000000000000000000000000000..8c3ca42f4144e0669d3ea02e8d1c6f7dc01999b9 GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!T!2rA>uv@HAle8ffeawn!N9PS zf#LuE|3I!t>B&r>5L-!*U$FR`Cqdl|T^A=!0*d&0x;TbZ+)C}YZ&Ihoe-EnRp6sXr f=XYv<%!D5dQMqh3QVOsBfvop*^>bP0l+XkKlL0=N literal 0 HcmV?d00001 diff --git a/public/images/lint/message-warning.png b/public/images/lint/message-warning.png new file mode 100644 index 0000000000000000000000000000000000000000..07472d049cd0857d4b3168ab457643a7ef07d1fd GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!S%6Q7>;K&h@7FT`Nlf%>J4g@+ z-mPc&ww2-c4u*fbKwO~U!&dO literal 0 HcmV?d00001 diff --git a/public/js/lib/editor/index.js b/public/js/lib/editor/index.js index 291dd0a4..37257871 100644 --- a/public/js/lib/editor/index.js +++ b/public/js/lib/editor/index.js @@ -3,6 +3,7 @@ import * as utils from './utils' import config from './config' import statusBarTemplate from './statusbar.html' import toolBarTemplate from './toolbar.html' +import './markdown-lint' /* config section */ const isMac = CodeMirror.keyMap.default === CodeMirror.keyMap.macDefault @@ -552,6 +553,7 @@ export default class Editor { this.editor = CodeMirror.fromTextArea(textit, { mode: defaultEditorMode, backdrop: defaultEditorMode, + lint: true, keyMap: 'sublime', viewportMargin: viewportMargin, styleActiveLine: true, @@ -573,7 +575,8 @@ export default class Editor { gutters: [ 'CodeMirror-linenumbers', 'authorship-gutters', - 'CodeMirror-foldgutter' + 'CodeMirror-foldgutter', + 'CodeMirror-lint-markers' ], extraKeys: this.defaultExtraKeys, flattenSpans: true, diff --git a/public/js/lib/editor/markdown-lint/index.js b/public/js/lib/editor/markdown-lint/index.js new file mode 100644 index 00000000..ea4bd778 --- /dev/null +++ b/public/js/lib/editor/markdown-lint/index.js @@ -0,0 +1,42 @@ +import markdownlint from 'markdownlint' + +// load lint plugin explicitly +import 'script-loader!@hackmd/codemirror/addon/lint/lint' +import './lint.css' + +(function(mod) { + mod(CodeMirror); +})(function(CodeMirror) { + function validator(text, options) { + return lint(text).map(error => { + const lineNumber = error.lineNumber - 1 + + let start, end + if (error.errorRange) { + start = error.errorRange[0] - 1 + end = error.errorRange[1] - 1 + } else { + start = 0 + end = -1 + } + + return { + message: error.ruleDescription, + severity: 'error', + from: CodeMirror.Pos(lineNumber, start), + to: CodeMirror.Pos(lineNumber, end) + } + }) + } + + CodeMirror.registerHelper('lint', 'markdown', validator); +}); + +function lint (content) { + const { content: errors } = markdownlint.sync({ + strings: { + content + } + }) + return errors +} diff --git a/public/js/lib/editor/markdown-lint/lint.css b/public/js/lib/editor/markdown-lint/lint.css new file mode 100644 index 00000000..d474419a --- /dev/null +++ b/public/js/lib/editor/markdown-lint/lint.css @@ -0,0 +1,72 @@ +/* The lint marker gutter */ +.CodeMirror-lint-markers { + width: 16px; +} + +.CodeMirror-lint-tooltip { + background-color: #ffd; + border: 1px solid black; + border-radius: 4px 4px 4px 4px; + color: black; + font-family: monospace; + font-size: 10pt; + overflow: hidden; + padding: 2px 5px; + position: fixed; + white-space: pre; + white-space: pre-wrap; + z-index: 100; + max-width: 600px; + opacity: 0; + transition: opacity .4s; + -moz-transition: opacity .4s; + -webkit-transition: opacity .4s; + -o-transition: opacity .4s; + -ms-transition: opacity .4s; +} + +.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning { + background-position: left bottom; + background-repeat: repeat-x; +} + +.CodeMirror-lint-mark-error { + background-image: url(/images/lint/mark-error.png); + ; +} + +.CodeMirror-lint-mark-warning { + background-image: url(/images/lint/mark-warning.png); +} + +.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning { + background-position: center center; + background-repeat: no-repeat; + cursor: pointer; + display: inline-block; + height: 16px; + width: 16px; + vertical-align: middle; + position: relative; +} + +.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning { + padding-left: 18px; + background-position: top left; + background-repeat: no-repeat; +} + +.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { + background-image: url(/images/lint/message-error.png); +} + +.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning { + background-image: url(/images/lint/message-warning.png); +} + +.CodeMirror-lint-marker-multiple { + background-image: url(/images/lint/mark-multiple.png); + background-repeat: no-repeat; + background-position: right bottom; + width: 100%; height: 100%; +} diff --git a/public/js/url.js b/public/js/url.js new file mode 100644 index 00000000..22ed110b --- /dev/null +++ b/public/js/url.js @@ -0,0 +1 @@ +exports.URL = window.URL diff --git a/webpack.common.js b/webpack.common.js index a7fe2b86..cd5b5338 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -167,7 +167,11 @@ module.exports = { to: 'reveal.js/plugin' } ]), - new MiniCssExtractPlugin() + new MiniCssExtractPlugin(), + new webpack.NormalModuleReplacementPlugin( + /^url$/, + path.resolve(__dirname, './public/js/url.js') + ) ], entry: { @@ -374,7 +378,8 @@ module.exports = { 'js-sequence-diagrams': path.join(__dirname, 'node_modules/@hackmd/js-sequence-diagrams/build/main.js'), vega: path.join(__dirname, 'node_modules/vega/build/vega.min.js'), 'vega-lite': path.join(__dirname, 'node_modules/vega-lite/build/vega-lite.min.js'), - 'vega-embed': path.join(__dirname, 'node_modules/vega-embed/build/vega-embed.min.js') + 'vega-embed': path.join(__dirname, 'node_modules/vega-embed/build/vega-embed.min.js'), + 'markdown-it': path.join(__dirname, 'node_modules/markdown-it/dist/markdown-it.js') } }, diff --git a/yarn.lock b/yarn.lock index 6db3a214..7a708b09 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7890,7 +7890,7 @@ markdown-it-sup@~1.0.0: resolved "https://registry.yarnpkg.com/markdown-it-sup/-/markdown-it-sup-1.0.0.tgz#cb9c9ff91a5255ac08f3fd3d63286e15df0a1fc3" integrity sha1-y5yf+RpSVawI8/09YyhuFd8KH8M= -markdown-it@~9.0.1: +markdown-it@9.0.1, markdown-it@~9.0.1: version "9.0.1" resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-9.0.1.tgz#aafe363c43718720b6575fd10625cde6e4ff2d47" integrity sha512-XC9dMBHg28Xi7y5dPuLjM61upIGPJG8AiHNHYqIaXER2KNnn7eKnM5/sF0ImNnyoV224Ogn9b1Pck8VH4k0bxw== @@ -7921,6 +7921,13 @@ markdown-table@^1.1.0: resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.3.tgz#9fcb69bcfdb8717bfd0398c6ec2d93036ef8de60" integrity sha512-1RUZVgQlpJSPWYbFSpmudq5nHY1doEIv89gBtF0s4gW1GF2XorxcA/70M5vq7rLv0a6mhOUccRsqkwhwLCIQ2Q== +markdownlint@^0.16.0: + version "0.16.0" + resolved "https://registry.yarnpkg.com/markdownlint/-/markdownlint-0.16.0.tgz#69f73cc755a44231fbe5dc7c37a5909cedc0ac6e" + integrity sha512-Zo+iPezP3eM6lLhKepkUw+X98H44lipIdx4d6faaugfB0+7VuDB3R0hXmx7z9F1N3/ypn46oOFgAD9iF++Ie6A== + dependencies: + markdown-it "9.0.1" + marked@~0.6.2: version "0.6.3" resolved "https://registry.yarnpkg.com/marked/-/marked-0.6.3.tgz#79babad78af638ba4d522a9e715cdfdd2429e946" From 2852be09809f0965c31be8dfe24d522862f57e4f Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Fri, 16 Aug 2019 10:30:34 +0800 Subject: [PATCH 2/6] Tweak gutter styles Signed-off-by: Yukai Huang --- public/js/lib/editor/index.js | 4 ++-- public/js/lib/editor/markdown-lint/lint.css | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/public/js/lib/editor/index.js b/public/js/lib/editor/index.js index 37257871..6f7cb2be 100644 --- a/public/js/lib/editor/index.js +++ b/public/js/lib/editor/index.js @@ -573,10 +573,10 @@ export default class Editor { autoCloseTags: true, foldGutter: true, gutters: [ + 'CodeMirror-lint-markers', 'CodeMirror-linenumbers', 'authorship-gutters', - 'CodeMirror-foldgutter', - 'CodeMirror-lint-markers' + 'CodeMirror-foldgutter' ], extraKeys: this.defaultExtraKeys, flattenSpans: true, diff --git a/public/js/lib/editor/markdown-lint/lint.css b/public/js/lib/editor/markdown-lint/lint.css index d474419a..a8707173 100644 --- a/public/js/lib/editor/markdown-lint/lint.css +++ b/public/js/lib/editor/markdown-lint/lint.css @@ -48,6 +48,7 @@ width: 16px; vertical-align: middle; position: relative; + margin-left: 5px; } .CodeMirror-lint-message-error, .CodeMirror-lint-message-warning { From 31765a9d3432a25d2193d89804dbfed7624424a9 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Fri, 16 Aug 2019 23:22:58 +0800 Subject: [PATCH 3/6] Make message more verbose & tweak style Signed-off-by: Yukai Huang --- public/js/lib/editor/markdown-lint/index.js | 4 ++-- public/js/lib/editor/markdown-lint/lint.css | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/public/js/lib/editor/markdown-lint/index.js b/public/js/lib/editor/markdown-lint/index.js index ea4bd778..7dd020cb 100644 --- a/public/js/lib/editor/markdown-lint/index.js +++ b/public/js/lib/editor/markdown-lint/index.js @@ -1,6 +1,6 @@ import markdownlint from 'markdownlint' -// load lint plugin explicitly +// load CM lint plugin explicitly import 'script-loader!@hackmd/codemirror/addon/lint/lint' import './lint.css' @@ -21,7 +21,7 @@ import './lint.css' } return { - message: error.ruleDescription, + messageHTML: `${error.ruleNames.join('/')}: ${error.ruleDescription}`, severity: 'error', from: CodeMirror.Pos(lineNumber, start), to: CodeMirror.Pos(lineNumber, end) diff --git a/public/js/lib/editor/markdown-lint/lint.css b/public/js/lib/editor/markdown-lint/lint.css index a8707173..0244eae2 100644 --- a/public/js/lib/editor/markdown-lint/lint.css +++ b/public/js/lib/editor/markdown-lint/lint.css @@ -4,11 +4,11 @@ } .CodeMirror-lint-tooltip { - background-color: #ffd; - border: 1px solid black; - border-radius: 4px 4px 4px 4px; - color: black; - font-family: monospace; + background-color: #333333; + border: 1px solid #eeeeee; + border-radius: 4px; + color: white; + font-family: "Source Code Pro", Consolas, monaco, monospace; font-size: 10pt; overflow: hidden; padding: 2px 5px; @@ -32,7 +32,6 @@ .CodeMirror-lint-mark-error { background-image: url(/images/lint/mark-error.png); - ; } .CodeMirror-lint-mark-warning { @@ -52,9 +51,10 @@ } .CodeMirror-lint-message-error, .CodeMirror-lint-message-warning { - padding-left: 18px; + padding-left: 20px; background-position: top left; background-repeat: no-repeat; + background-position-y: 2px; } .CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { From 968e042b05a64bf1d101f9573332cfe4b8c59694 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Fri, 16 Aug 2019 23:27:19 +0800 Subject: [PATCH 4/6] Cleanup Signed-off-by: Yukai Huang --- public/js/lib/editor/markdown-lint/index.js | 26 +++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/public/js/lib/editor/markdown-lint/index.js b/public/js/lib/editor/markdown-lint/index.js index 7dd020cb..24400595 100644 --- a/public/js/lib/editor/markdown-lint/index.js +++ b/public/js/lib/editor/markdown-lint/index.js @@ -7,21 +7,23 @@ import './lint.css' (function(mod) { mod(CodeMirror); })(function(CodeMirror) { - function validator(text, options) { + function validator(text) { return lint(text).map(error => { - const lineNumber = error.lineNumber - 1 + const { + ruleNames, + ruleDescription, + lineNumber: ln, + errorRange + } = error + const lineNumber = ln - 1 - let start, end - if (error.errorRange) { - start = error.errorRange[0] - 1 - end = error.errorRange[1] - 1 - } else { - start = 0 - end = -1 + let start = 0, end = -1 + if (errorRange) { + [start, end] = errorRange.map(r => r - 1) } return { - messageHTML: `${error.ruleNames.join('/')}: ${error.ruleDescription}`, + messageHTML: `${ruleNames.join('/')}: ${ruleDescription}`, severity: 'error', from: CodeMirror.Pos(lineNumber, start), to: CodeMirror.Pos(lineNumber, end) @@ -29,8 +31,8 @@ import './lint.css' }) } - CodeMirror.registerHelper('lint', 'markdown', validator); -}); + CodeMirror.registerHelper('lint', 'markdown', validator) +}) function lint (content) { const { content: errors } = markdownlint.sync({ From ad5be66206046038ca91580b352e262545fb3a3f Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Sat, 17 Aug 2019 00:17:22 +0800 Subject: [PATCH 5/6] Add status bar icon to toggle linter Signed-off-by: Yukai Huang --- public/css/index.css | 5 ++++ public/js/lib/editor/index.js | 40 +++++++++++++++++++++++++++-- public/js/lib/editor/statusbar.html | 3 +++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/public/css/index.css b/public/css/index.css index d9ebf6de..5663c1bb 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -513,6 +513,7 @@ div[contenteditable]:empty:not(:focus):before{ .status-bar .status-indicators .status-keymap > a, .status-bar .status-indicators .status-theme > a, .status-bar .status-indicators .status-spellcheck > a, +.status-bar .status-indicators .status-linter > a, .status-bar .status-indicators .status-preferences > a { color: inherit; text-decoration: none; @@ -520,6 +521,7 @@ div[contenteditable]:empty:not(:focus):before{ .status-bar .status-indicators .status-theme, .status-bar .status-indicators .status-spellcheck, +.status-bar .status-indicators .status-linter, .status-bar .status-indicators .status-preferences { padding: 0 4.3px; } @@ -540,17 +542,20 @@ div[contenteditable]:empty:not(:focus):before{ } .ui-theme-toggle, +.ui-linter-toggle, .ui-spellcheck-toggle { opacity: 0.2; cursor: pointer; } .ui-theme-toggle.active, +.ui-linter-toggle.active, .ui-spellcheck-toggle.active { opacity: 1; } .ui-theme-toggle:hover, +.ui-linter-toggle:hover, .ui-spellcheck-toggle:hover { opacity: 0.8; } diff --git a/public/js/lib/editor/index.js b/public/js/lib/editor/index.js index 6f7cb2be..5c94be69 100644 --- a/public/js/lib/editor/index.js +++ b/public/js/lib/editor/index.js @@ -232,6 +232,7 @@ export default class Editor { this.statusLength = this.statusBar.find('.status-length') this.statusTheme = this.statusBar.find('.status-theme') this.statusSpellcheck = this.statusBar.find('.status-spellcheck') + this.statusLinter = this.statusBar.find('.status-linter') this.statusPreferences = this.statusBar.find('.status-preferences') this.statusPanel = this.editor.addPanel(this.statusBar[0], { position: 'bottom' @@ -241,6 +242,7 @@ export default class Editor { this.setKeymap() this.setTheme() this.setSpellcheck() + this.setLinter() this.setPreferences() } @@ -499,6 +501,42 @@ export default class Editor { } } + toggleLinter (enable) { + const gutters = this.editor.getOption('gutters') + const lintGutter = 'CodeMirror-lint-markers' + + if (enable) { + if (!gutters.includes(lintGutter)) { + this.editor.setOption('gutters', [lintGutter, ...gutters]) + } + Cookies.set('linter', true, { + expires: 365 + }) + } else { + this.editor.setOption('gutters', gutters.filter(g => g !== lintGutter)) + Cookies.remove('linter') + } + this.editor.setOption('lint', enable) + } + + setLinter () { + const linterToggle = this.statusLinter.find('.ui-linter-toggle') + + const updateLinterStatus = (enable) => { + linterToggle.toggleClass('active', enable) + } + + linterToggle.click(() => { + const lintEnable = this.editor.getOption('lint') + this.toggleLinter.bind(this)(!lintEnable) + updateLinterStatus(!lintEnable) + }) + + const enable = !!Cookies.get('linter') + this.toggleLinter.bind(this)(enable) + updateLinterStatus(enable) + } + resetEditorKeymapToBrowserKeymap () { var keymap = this.editor.getOption('keyMap') if (!this.jumpToAddressBarKeymapValue) { @@ -553,7 +591,6 @@ export default class Editor { this.editor = CodeMirror.fromTextArea(textit, { mode: defaultEditorMode, backdrop: defaultEditorMode, - lint: true, keyMap: 'sublime', viewportMargin: viewportMargin, styleActiveLine: true, @@ -573,7 +610,6 @@ export default class Editor { autoCloseTags: true, foldGutter: true, gutters: [ - 'CodeMirror-lint-markers', 'CodeMirror-linenumbers', 'authorship-gutters', 'CodeMirror-foldgutter' diff --git a/public/js/lib/editor/statusbar.html b/public/js/lib/editor/statusbar.html index 24cbf6c2..c4c796bc 100644 --- a/public/js/lib/editor/statusbar.html +++ b/public/js/lib/editor/statusbar.html @@ -37,5 +37,8 @@
+
+ +
From d7854cd02c12348fc19d96758bb9653cfca809a2 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Sun, 18 Aug 2019 14:09:12 +0800 Subject: [PATCH 6/6] Make linter happy Signed-off-by: Yukai Huang --- public/js/lib/editor/markdown-lint/index.js | 13 +++++++------ webpack.common.js | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/public/js/lib/editor/markdown-lint/index.js b/public/js/lib/editor/markdown-lint/index.js index 24400595..f8fbfc2e 100644 --- a/public/js/lib/editor/markdown-lint/index.js +++ b/public/js/lib/editor/markdown-lint/index.js @@ -1,13 +1,14 @@ +/* global CodeMirror */ import markdownlint from 'markdownlint' // load CM lint plugin explicitly -import 'script-loader!@hackmd/codemirror/addon/lint/lint' +import '@hackmd/codemirror/addon/lint/lint' import './lint.css' -(function(mod) { - mod(CodeMirror); -})(function(CodeMirror) { - function validator(text) { +(function (mod) { + mod(CodeMirror) +})(function (CodeMirror) { + function validator (text) { return lint(text).map(error => { const { ruleNames, @@ -17,7 +18,7 @@ import './lint.css' } = error const lineNumber = ln - 1 - let start = 0, end = -1 + let start = 0; let end = -1 if (errorRange) { [start, end] = errorRange.map(r => r - 1) } diff --git a/webpack.common.js b/webpack.common.js index cd5b5338..bd61b9bf 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -464,6 +464,11 @@ module.exports = { loader: 'url-loader', options: { limit: '10000', mimetype: 'image/gif' } }] + }, { + test: /@hackmd\/codemirror\/addon\/lint\/lint/, + use: [{ + loader: 'script-loader' + }] }] }, node: {