Skip to content

Commit 010dc47

Browse files
committed
feat: add html lint pref disable, fix mainview integ tests due to html lint panel
1 parent 594fae6 commit 010dc47

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

src/extensions/default/HTMLCodeHints/html-lint.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,20 @@ define(function (require, exports, module) {
3131
Strings = brackets.getModule("strings"),
3232
EditorManager = brackets.getModule("editor/EditorManager"),
3333
ProjectManager = brackets.getModule("project/ProjectManager"),
34+
PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
3435
IndexingWorker = brackets.getModule("worker/IndexingWorker");
3536

3637
IndexingWorker.loadScriptInWorker(`${module.uri}/../worker/html-worker.js`);
3738

39+
const prefs = PreferencesManager.getExtensionPrefs("HTMLLint");
40+
const PREFS_HTML_LINT_DISABLED = "disabled";
41+
42+
prefs.definePreference(PREFS_HTML_LINT_DISABLED, "boolean", false, {
43+
description: Strings.DESCRIPTION_HTML_LINT_DISABLE
44+
}).on("change", function () {
45+
CodeInspection.requestRun(Strings.HTML_LINT_NAME);
46+
});
47+
3848
function getTypeFromSeverity(sev) {
3949
// https://html-validate.org/guide/api/getting-started.html
4050
switch (sev) {
@@ -82,7 +92,7 @@ define(function (require, exports, module) {
8292
name: Strings.HTML_LINT_NAME,
8393
scanFileAsync: lintOneFile,
8494
canInspect: function (_fullPath) {
85-
return true; // no restrictions for now
95+
return !prefs.get(PREFS_HTML_LINT_DISABLED);
8696
}
8797
});
8898
});

src/extensions/default/JSLint/ESLint.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ define(function (require, exports, module) {
269269
if(!Phoenix.isNativeApp) {
270270
return;
271271
}
272+
// just do a dummy eslint to warm up/load the eslint runner service for the project and dispose old service
273+
// on project switch.
272274
NodeUtils.ESLintFile("console.log();", "a.js", ProjectManager.getProjectRoot().fullPath)
273275
.catch(e=>{
274276
console.error(`Error warming up ESLint service`, e);

src/nls/root/strings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ define({
970970
"DESCRIPTION_NO_HINTS_ON_DOT": "true to not automatically show JS code hints when . is typed",
971971
"DESCRIPTION_JSHINT_DISABLE": "true to disable JSHints linter in problems panel",
972972
"DESCRIPTION_ESLINT_DISABLE": "true to disable ESLint linter in problems panel",
973+
"DESCRIPTION_HTML_LINT_DISABLE": "true to disable HTML linter in problems panel",
973974
"DESCRIPTION_ESLINT_FAILED": "ESLint Failed ({0}). Make sure the project contains valid <a href='https://eslint.org/docs/latest/use/configure/configuration-files'>Configuration Files</a>",
974975
"DESCRIPTION_ESLINT_USE_NATIVE_APP": "ESLint is only available in the Desktop app. Download it from <a href='https://phcode.io'>phcode.io</a>",
975976
"DESCRIPTION_ESLINT_LOAD_FAILED": "Failed to load ESLint for this project. {APP_NAME} supports only ESLint versions above 7.",

src/thirdparty/licences/language-services.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ Copyright (c) Microsoft
1010
MIT License
1111
Copyright (c) 2017 Chai.js Assertion Library
1212

13+
## html-validate
14+
MIT License
15+
Copyright (c) 2017 David Sveningsson <[email protected]>
16+
https://html-validate.org/
17+
1318
## test/thirparty/mocha
1419
(The MIT License)
1520
Copyright (c) 2011-2022 OpenJS Foundation and contributors, https://openjsf.org

test/spec/MainViewManager-integ-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ define(function (require, exports, module) {
3434
Dialogs, // loaded from brackets.test
3535
DefaultDialogs,
3636
WorkspaceManager,
37+
PreferencesManager,
3738
Menus,
3839
SpecRunnerUtils = require("spec/SpecRunnerUtils"),
3940
KeyEvent = require("utils/KeyEvent");
@@ -58,6 +59,7 @@ define(function (require, exports, module) {
5859
DocumentManager = testWindow.brackets.test.DocumentManager;
5960
EditorManager = testWindow.brackets.test.EditorManager;
6061
DefaultDialogs = testWindow.brackets.test.DefaultDialogs;
62+
PreferencesManager = testWindow.brackets.test.PreferencesManager;
6163
MainViewManager = testWindow.brackets.test.MainViewManager;
6264
ProjectManager = testWindow.brackets.test.ProjectManager;
6365
WorkspaceManager = testWindow.brackets.test.WorkspaceManager;
@@ -71,6 +73,12 @@ define(function (require, exports, module) {
7173
beforeAll(async function () {
7274
testWindow = await SpecRunnerUtils.createTestWindowAndRun({forceReload: true});
7375
await _init();
76+
// we have to disable html lint here as html lint panel interferes with the panel view tests,
77+
// which was created before we added html lint. Since we only test the panel functionality, not having html
78+
// lint won't impact test correctness.
79+
const prefs = PreferencesManager.getExtensionPrefs("HTMLLint");
80+
const PREFS_HTML_LINT_DISABLED = "disabled";
81+
prefs.set(PREFS_HTML_LINT_DISABLED, true);
7482
}, 30000);
7583

7684
afterAll(async function () {
@@ -83,6 +91,7 @@ define(function (require, exports, module) {
8391
EditorManager = null;
8492
ProjectManager = null;
8593
FileSystem = null;
94+
PreferencesManager = null;
8695
await SpecRunnerUtils.closeTestWindow();
8796
}, 30000);
8897

0 commit comments

Comments
 (0)