Skip to content

Commit 171649b

Browse files
author
Ives van Hoorne
committed
Add linter option
1 parent 2035d2d commit 171649b

File tree

2 files changed

+24
-8
lines changed
  • packages/app/src/app
    • components/CodeEditor/Monaco
    • pages/common/Modals/PreferencesModal/EditorPageSettings/EditorSettings

2 files changed

+24
-8
lines changed

packages/app/src/app/components/CodeEditor/Monaco/index.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ class MonacoEditor extends React.Component<Props, State> implements Editor {
331331

332332
changeSettings = (settings: $PropertyType<Props, 'settings'>) => {
333333
this.settings = settings;
334+
if (settings.lintEnabled && !this.lintWorker) {
335+
this.setupLintWorker();
336+
}
337+
334338
this.editor.updateOptions(this.getEditorOptions());
335339
this.forceUpdate();
336340
};
@@ -699,14 +703,16 @@ class MonacoEditor extends React.Component<Props, State> implements Editor {
699703

700704
lint = async (code: string, title: string, version: number) => {
701705
const mode = await this.getMode(title);
702-
if (mode === 'javascript' || mode === 'vue') {
703-
if (this.lintWorker) {
704-
this.lintWorker.postMessage({
705-
code,
706-
title,
707-
version,
708-
template: this.sandbox.template,
709-
});
706+
if (this.settings.lintEnabled) {
707+
if (mode === 'javascript' || mode === 'vue') {
708+
if (this.lintWorker) {
709+
this.lintWorker.postMessage({
710+
code,
711+
title,
712+
version,
713+
template: this.sandbox.template,
714+
});
715+
}
710716
}
711717
}
712718
};

packages/app/src/app/pages/common/Modals/PreferencesModal/EditorPageSettings/EditorSettings/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ function EditorSettings({ store, signals }) {
5454
Automatically download type definitions for dependencies.
5555
</SubDescription>
5656
<Rule />
57+
<PaddedPreference
58+
title="ESLint"
59+
type="boolean"
60+
tooltip="Made possible by ESLint"
61+
{...bindValue('lintEnabled')}
62+
/>
63+
<SubDescription>
64+
Whether linting as you type should be enabled.
65+
</SubDescription>
66+
<Rule />
5767
<PaddedPreference
5868
title="Prettify on save"
5969
type="boolean"

0 commit comments

Comments
 (0)