Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Option to disable when no .htmlhintrc file is found #172

Merged
merged 6 commits into from
Aug 29, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ let generateRange;
let tinyPromisify;
let stripJSONComments;

// Configuration
let disableWhenNoHtmlhintConfig;

// Internal variables
const phpEmbeddedScope = 'text.html.php';

// Internal functions
const getConfig = async (filePath) => {
const readFile = tinyPromisify(fsReadFile);
const configPath = await findAsync(dirname(filePath), '.htmlhintrc');
Expand Down Expand Up @@ -86,6 +91,9 @@ export default {
// Add the current scopes
Array.prototype.push.apply(this.grammarScopes, scopes);
}));
this.subscriptions.add(atom.config.observe('linter-htmlhint.disableWhenNoHtmhintConfig', (value) => {
disableWhenNoHtmlhintConfig = value;
}));
},

deactivate() {
Expand Down Expand Up @@ -123,6 +131,9 @@ export default {
loadDeps();

const ruleset = await getConfig(filePath);
if (!ruleset && disableWhenNoHtmlhintConfig) {
return null;
}

const messages = HTMLHint.verify(text, ruleset || undefined);

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"items": {
"type": "string"
}
},
"disableWhenNoHtmhintConfig": {
"title": "Disable when no HTMLHint config is found",
"type": "boolean",
"default": true
}
},
"scripts": {
Expand Down