lint on import
This commit is contained in:
parent
ca8eda20ff
commit
562998e4b2
30
edit/edit.js
30
edit/edit.js
|
@ -470,7 +470,7 @@ function indicateCodeChange(cm, change) {
|
||||||
cm.stylusChanges = cm.stylusChanges || [];
|
cm.stylusChanges = cm.stylusChanges || [];
|
||||||
cm.stylusChanges.push(change);
|
cm.stylusChanges.push(change);
|
||||||
}
|
}
|
||||||
updateLintReportIfEnabled(cm);
|
updateLintReport(cm);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSectionForChild(e) {
|
function getSectionForChild(e) {
|
||||||
|
@ -597,7 +597,7 @@ window.onbeforeunload = () => {
|
||||||
if (isCleanGlobal()) {
|
if (isCleanGlobal()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateLintReportIfEnabled(null, 0);
|
updateLintReport(null, 0);
|
||||||
// neither confirm() nor custom messages work in modern browsers but just in case
|
// neither confirm() nor custom messages work in modern browsers but just in case
|
||||||
return t('styleChangesNotSaved');
|
return t('styleChangesNotSaved');
|
||||||
};
|
};
|
||||||
|
@ -1275,21 +1275,9 @@ function initWithStyle({style, codeIsUpdated}) {
|
||||||
|
|
||||||
function add() {
|
function add() {
|
||||||
const sectionDiv = addSection(null, queue.shift());
|
const sectionDiv = addSection(null, queue.shift());
|
||||||
maximizeCodeHeight(sectionDiv, !queue.length);
|
const isLast = !queue.length;
|
||||||
const cm = sectionDiv.CodeMirror;
|
maximizeCodeHeight(sectionDiv, isLast);
|
||||||
if (prefs.get('editor.linter')) {
|
updateLintReport(sectionDiv.CodeMirror, !isLast && 100);
|
||||||
setTimeout(() => {
|
|
||||||
cm.setOption('lint', linterConfig.getForCodeMirror());
|
|
||||||
updateLintReport(cm, 100);
|
|
||||||
if (!queue.length) {
|
|
||||||
setTimeout(() => {
|
|
||||||
const state = cm.state.lint || {};
|
|
||||||
clearTimeout(state.renderTimeout);
|
|
||||||
renderLintReport();
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1427,14 +1415,8 @@ function validate() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLintReportIfEnabled(cm, time) {
|
|
||||||
if (CodeMirror.lint) {
|
|
||||||
updateLintReport(cm, time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
updateLintReportIfEnabled(null, 0);
|
updateLintReport(null, 0);
|
||||||
|
|
||||||
// save the contents of the CodeMirror editors back into the textareas
|
// save the contents of the CodeMirror editors back into the textareas
|
||||||
for (let i = 0; i < editors.length; i++) {
|
for (let i = 0; i < editors.length; i++) {
|
||||||
|
|
22
edit/lint.js
22
edit/lint.js
|
@ -191,7 +191,24 @@ function updateLinter({immediately} = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLintReport(cm, delay) {
|
function updateLintReport(cm, delay) {
|
||||||
const state = cm && cm.state.lint || {};
|
if (!CodeMirror.defaults.lint) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cm && !cm.options.lint) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (cm.options.lint) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cm.setOption('lint', linterConfig.getForCodeMirror());
|
||||||
|
if (!delay) {
|
||||||
|
setTimeout(() => {
|
||||||
|
clearTimeout((cm.state.lint || {}).renderTimeout);
|
||||||
|
renderLintReport();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const state = cm && cm.state && cm.state.lint || {};
|
||||||
if (delay === 0) {
|
if (delay === 0) {
|
||||||
// immediately show pending csslint/stylelint messages in onbeforeunload and save
|
// immediately show pending csslint/stylelint messages in onbeforeunload and save
|
||||||
clearTimeout(state.lintTimeout);
|
clearTimeout(state.lintTimeout);
|
||||||
|
@ -213,9 +230,6 @@ function updateLintReport(cm, delay) {
|
||||||
}, delay, cm);
|
}, delay, cm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!state) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// user is editing right now: postpone updating the report for the new issues (default: 500ms lint + 4500ms)
|
// user is editing right now: postpone updating the report for the new issues (default: 500ms lint + 4500ms)
|
||||||
// or update it as soon as possible (default: 500ms lint + 100ms) in case an existing issue was just fixed
|
// or update it as soon as possible (default: 500ms lint + 100ms) in case an existing issue was just fixed
|
||||||
clearTimeout(state.reportTimeout);
|
clearTimeout(state.reportTimeout);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user