Skip to content

Commit f178a53

Browse files
icecream17aminya
authored andcommitted
lint
1 parent de2bda0 commit f178a53

File tree

8 files changed

+211
-166
lines changed

8 files changed

+211
-166
lines changed

packages/language-c/lib/main.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
exports.activate = function () {
1+
exports.activate = function() {
22
// Highlight macro bodies as C/C++
33
for (const language of ['c', 'cpp']) {
44
for (const nodeType of ['preproc_def', 'preproc_function_def']) {
55
atom.grammars.addInjectionPoint(`source.${language}`, {
66
type: nodeType,
7-
language (node) { return language },
8-
content (node) { return node.lastNamedChild }
9-
})
7+
language(node) {
8+
return language;
9+
},
10+
content(node) {
11+
return node.lastNamedChild;
12+
}
13+
});
1014
}
1115
}
12-
}
16+
};

packages/language-html/lib/main.js

+44-20
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,63 @@
1-
exports.activate = function () {
1+
exports.activate = function() {
22
atom.grammars.addInjectionPoint('text.html.basic', {
33
type: 'script_element',
4-
language () { return 'javascript' },
5-
content (node) { return node.child(1) }
6-
})
4+
language() {
5+
return 'javascript';
6+
},
7+
content(node) {
8+
return node.child(1);
9+
}
10+
});
711

812
atom.grammars.addInjectionPoint('text.html.basic', {
913
type: 'style_element',
10-
language () { return 'css' },
11-
content (node) { return node.child(1) }
12-
})
14+
language() {
15+
return 'css';
16+
},
17+
content(node) {
18+
return node.child(1);
19+
}
20+
});
1321

1422
atom.grammars.addInjectionPoint('text.html.ejs', {
1523
type: 'template',
16-
language (node) { return 'javascript' },
17-
content (node) { return node.descendantsOfType('code') },
24+
language(node) {
25+
return 'javascript';
26+
},
27+
content(node) {
28+
return node.descendantsOfType('code');
29+
},
1830
newlinesBetween: true
19-
})
31+
});
2032

2133
atom.grammars.addInjectionPoint('text.html.ejs', {
2234
type: 'template',
23-
language (node) { return 'html' },
24-
content (node) { return node.descendantsOfType('content') }
25-
})
35+
language(node) {
36+
return 'html';
37+
},
38+
content(node) {
39+
return node.descendantsOfType('content');
40+
}
41+
});
2642

2743
atom.grammars.addInjectionPoint('text.html.erb', {
2844
type: 'template',
29-
language (node) { return 'ruby' },
30-
content (node) { return node.descendantsOfType('code') },
45+
language(node) {
46+
return 'ruby';
47+
},
48+
content(node) {
49+
return node.descendantsOfType('code');
50+
},
3151
newlinesBetween: true
32-
})
52+
});
3353

3454
atom.grammars.addInjectionPoint('text.html.erb', {
3555
type: 'template',
36-
language (node) { return 'html' },
37-
content (node) { return node.descendantsOfType('content') }
38-
})
39-
}
56+
language(node) {
57+
return 'html';
58+
},
59+
content(node) {
60+
return node.descendantsOfType('content');
61+
}
62+
});
63+
};
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
const dedent = require('dedent')
1+
const dedent = require('dedent');
22

33
describe('Tree-sitter HTML grammar', () => {
4-
54
beforeEach(async () => {
6-
atom.config.set('core.useTreeSitterParsers', true)
7-
await atom.packages.activatePackage('language-html')
8-
})
5+
atom.config.set('core.useTreeSitterParsers', true);
6+
await atom.packages.activatePackage('language-html');
7+
});
98

109
it('tokenizes punctuation in HTML tags and attributes', async () => {
11-
const editor = await atom.workspace.open(`test.html`)
10+
const editor = await atom.workspace.open(`test.html`);
1211

1312
editor.setText(dedent`
1413
<html lang="en">
@@ -18,64 +17,64 @@ describe('Tree-sitter HTML grammar', () => {
1817
</head>
1918
<body>
2019
</html>
21-
`)
20+
`);
2221

2322
// Tag punctuation.
2423
expect(editor.scopeDescriptorForBufferPosition([0, 0]).toString()).toBe(
2524
'.text.html.basic .source.html .punctuation.definition.tag.begin'
26-
)
25+
);
2726

2827
expect(editor.scopeDescriptorForBufferPosition([0, 15]).toString()).toBe(
2928
'.text.html.basic .source.html .punctuation.definition.tag.end'
30-
)
29+
);
3130

3231
expect(editor.scopeDescriptorForBufferPosition([6, 0]).toString()).toBe(
3332
'.text.html.basic .source.html .punctuation.definition.tag.begin'
34-
)
33+
);
3534

3635
expect(editor.scopeDescriptorForBufferPosition([6, 6]).toString()).toBe(
3736
'.text.html.basic .source.html .punctuation.definition.tag.end'
38-
)
37+
);
3938

4039
// Attribute-value pair punctuation.
4140
expect(editor.scopeDescriptorForBufferPosition([0, 10]).toString()).toBe(
4241
'.text.html.basic .source.html .punctuation.separator.key-value.html'
43-
)
42+
);
4443

4544
expect(editor.scopeDescriptorForBufferPosition([2, 18]).toString()).toBe(
4645
'.text.html.basic .source.html .punctuation.definition.string.begin'
47-
)
46+
);
4847

4948
expect(editor.scopeDescriptorForBufferPosition([2, 24]).toString()).toBe(
5049
'.text.html.basic .source.html .punctuation.definition.string.end'
51-
)
50+
);
5251

5352
// Ensure an attribute value delimited by single-quotes won't mark a
5453
// double-quote in the value as punctuation.
5554
expect(editor.scopeDescriptorForBufferPosition([3, 15]).toString()).toBe(
5655
'.text.html.basic .source.html .punctuation.definition.string.begin'
57-
)
56+
);
5857

5958
expect(editor.scopeDescriptorForBufferPosition([3, 16]).toString()).toBe(
6059
'.text.html.basic .source.html .string.html'
61-
)
60+
);
6261

6362
expect(editor.scopeDescriptorForBufferPosition([3, 17]).toString()).toBe(
6463
'.text.html.basic .source.html .punctuation.definition.string.end'
65-
)
64+
);
6665

6766
// Ensure an attribute value delimited by double-quotes won't mark a
6867
// single-quote in the value as punctuation.
6968
expect(editor.scopeDescriptorForBufferPosition([3, 27]).toString()).toBe(
7069
'.text.html.basic .source.html .punctuation.definition.string.begin'
71-
)
70+
);
7271

7372
expect(editor.scopeDescriptorForBufferPosition([3, 32]).toString()).toBe(
7473
'.text.html.basic .source.html .string.html'
75-
)
74+
);
7675

7776
expect(editor.scopeDescriptorForBufferPosition([3, 66]).toString()).toBe(
7877
'.text.html.basic .source.html .punctuation.definition.string.end'
79-
)
80-
})
81-
})
78+
);
79+
});
80+
});
+39-35
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,86 @@
1-
exports.activate = function () {
2-
if (!atom.grammars.addInjectionPoint) return
1+
exports.activate = function() {
2+
if (!atom.grammars.addInjectionPoint) return;
33

44
atom.grammars.addInjectionPoint('source.js', {
55
type: 'call_expression',
66

7-
language (callExpression) {
8-
const {firstChild} = callExpression
7+
language(callExpression) {
8+
const { firstChild } = callExpression;
99
switch (firstChild.type) {
1010
case 'identifier':
11-
return languageStringForTemplateTag(firstChild.text)
11+
return languageStringForTemplateTag(firstChild.text);
1212
case 'call_expression':
13-
return languageStringForTemplateTag(firstChild.children[0].text)
13+
return languageStringForTemplateTag(firstChild.children[0].text);
1414
case 'member_expression':
1515
if (firstChild.startPosition.row === firstChild.endPosition.row) {
16-
return languageStringForTemplateTag(firstChild.text)
16+
return languageStringForTemplateTag(firstChild.text);
1717
}
1818
}
1919
},
2020

21-
content (callExpression) {
22-
const {lastChild} = callExpression
21+
content(callExpression) {
22+
const { lastChild } = callExpression;
2323
if (lastChild.type === 'template_string') {
24-
return lastChild
24+
return lastChild;
2525
}
2626
}
27-
})
27+
});
2828

2929
atom.grammars.addInjectionPoint('source.js', {
3030
type: 'assignment_expression',
3131

32-
language (callExpression) {
33-
const {firstChild} = callExpression
32+
language(callExpression) {
33+
const { firstChild } = callExpression;
3434
if (firstChild.type === 'member_expression') {
3535
if (firstChild.lastChild.text === 'innerHTML') {
36-
return 'html'
36+
return 'html';
3737
}
3838
}
3939
},
4040

41-
content (callExpression) {
42-
const {lastChild} = callExpression
41+
content(callExpression) {
42+
const { lastChild } = callExpression;
4343
if (lastChild.type === 'template_string') {
44-
return lastChild
44+
return lastChild;
4545
}
4646
}
47-
})
47+
});
4848

4949
atom.grammars.addInjectionPoint('source.js', {
5050
type: 'regex_pattern',
51-
language (regex) { return 'regex' },
52-
content (regex) { return regex }
53-
})
51+
language(regex) {
52+
return 'regex';
53+
},
54+
content(regex) {
55+
return regex;
56+
}
57+
});
5458

5559
for (const scopeName of ['source.js', 'source.flow', 'source.ts']) {
5660
atom.grammars.addInjectionPoint(scopeName, {
5761
type: 'comment',
58-
language (comment) {
59-
if (comment.text.startsWith('/**')) return 'jsdoc'
62+
language(comment) {
63+
if (comment.text.startsWith('/**')) return 'jsdoc';
6064
},
61-
content (comment) {
62-
return comment
65+
content(comment) {
66+
return comment;
6367
}
64-
})
68+
});
6569
}
66-
}
70+
};
6771

68-
const CSS_REGEX = /\bstyled\b|\bcss\b/i
69-
const GQL_REGEX = /\bgraphql\b|\bgql\b/i
70-
const SQL_REGEX = /\bsql\b/i
72+
const CSS_REGEX = /\bstyled\b|\bcss\b/i;
73+
const GQL_REGEX = /\bgraphql\b|\bgql\b/i;
74+
const SQL_REGEX = /\bsql\b/i;
7175

72-
function languageStringForTemplateTag (tag) {
76+
function languageStringForTemplateTag(tag) {
7377
if (CSS_REGEX.test(tag)) {
74-
return 'CSS'
78+
return 'CSS';
7579
} else if (GQL_REGEX.test(tag)) {
76-
return 'GraphQL'
80+
return 'GraphQL';
7781
} else if (SQL_REGEX.test(tag)) {
78-
return 'SQL'
82+
return 'SQL';
7983
} else {
80-
return tag
84+
return tag;
8185
}
8286
}

packages/language-ruby/lib/main.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
exports.activate = function() {
2-
if (!atom.grammars.addInjectionPoint) return
2+
if (!atom.grammars.addInjectionPoint) return;
33

44
atom.grammars.addInjectionPoint('source.ruby', {
55
type: 'heredoc_body',
6-
language (node) { return node.lastChild.text },
7-
content (node) { return node }
8-
})
6+
language(node) {
7+
return node.lastChild.text;
8+
},
9+
content(node) {
10+
return node;
11+
}
12+
});
913

1014
atom.grammars.addInjectionPoint('source.ruby', {
1115
type: 'regex',
12-
language () { return 'regex' },
13-
content (node) { return node }
14-
})
15-
}
16+
language() {
17+
return 'regex';
18+
},
19+
content(node) {
20+
return node;
21+
}
22+
});
23+
};

0 commit comments

Comments
 (0)