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

Commit 00417d8

Browse files
committed
Make scopes configurable
Change the allowed scopes to a configurable setting, allowing any scope to be added that the user wants.
1 parent 207a035 commit 00417d8

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

lib/index.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
'use babel';
22

3-
const GRAMMAR_SCOPES = [
4-
'text.html.angular',
5-
'text.html.basic',
6-
'text.html.erb',
7-
'text.html.gohtml',
8-
'text.html.jsp',
9-
'text.html.mustache',
10-
'text.html.ruby'
11-
];
3+
import { CompositeDisposable } from 'atom';
4+
5+
const grammarScopes = [];
126

137
export function activate() {
148
require('atom-package-deps').install('linter-htmlhint');
9+
10+
const subscriptions = new CompositeDisposable();
11+
subscriptions.add(atom.config.observe('linter-htmlhint.enabledScopes', scopes => {
12+
// Remove any old scopes
13+
grammarScopes.splice(0, grammarScopes.length);
14+
// Add the current scopes
15+
Array.prototype.push.apply(grammarScopes, scopes);
16+
}));
1517
}
1618

1719
function getConfig(filePath) {
@@ -38,7 +40,7 @@ function getConfig(filePath) {
3840
export function provideLinter() {
3941
return {
4042
name: 'htmlhint',
41-
grammarScopes: GRAMMAR_SCOPES,
43+
grammarScopes,
4244
scope: 'file',
4345
lintOnFly: true,
4446
lint: editor => {

package.json

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,25 @@
99
"url": "https://github.com/AtomLinter/linter-htmlhint.git"
1010
},
1111
"engines": {
12-
"atom": ">=1.0.0 <2.0.0"
12+
"atom": ">=1.4.0 <2.0.0"
13+
},
14+
"configSchema": {
15+
"enabledScopes": {
16+
"description": "List of scopes to run HTMLHint on, run `Editor: Log Cursor Scope` to determine the scopes for a file.",
17+
"type": "array",
18+
"default": [
19+
"text.html.angular",
20+
"text.html.basic",
21+
"text.html.erb",
22+
"text.html.gohtml",
23+
"text.html.jsp",
24+
"text.html.mustache",
25+
"text.html.ruby"
26+
],
27+
"items": {
28+
"type": "string"
29+
}
30+
}
1331
},
1432
"scripts": {
1533
"test": "apm test",
@@ -40,18 +58,19 @@
4058
"eslintConfig": {
4159
"rules": {
4260
"comma-dangle": [
43-
2,
61+
"error",
4462
"never"
4563
],
46-
"global-require": 0,
64+
"global-require": "off",
4765
"import/no-unresolved": [
48-
2,
66+
"error",
4967
{
5068
"ignore": [
5169
"atom"
5270
]
5371
}
54-
]
72+
],
73+
"import/no-extraneous-dependencies": "off"
5574
},
5675
"extends": "airbnb-base",
5776
"globals": {

0 commit comments

Comments
 (0)