Skip to content

Commit b934847

Browse files
authored
limit ember template lint processing to correct files (#225)
1 parent d76107e commit b934847

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/main/kotlin/com/emberjs/hbs/linter/ember-template-lint/TemplateLintExternalAnnotator.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ class TemplateLintExternalAnnotator(onTheFly: Boolean = true) : JSLinterExternal
3232

3333
override fun acceptPsiFile(file: PsiFile): Boolean {
3434
val f = file
35-
return f.viewProvider is GtsFileViewProvider || f.viewProvider is HbFileViewProvider || file is JSFile
35+
val pkg = TemplateLintConfiguration.getInstance(file.project).extendedState.state.templateLintPackage
36+
val supportsJS = pkg.version?.let { it.major < 8 } ?: false
37+
return (f.name.endsWith(".hbs")
38+
|| (f.name.endsWith(".js") && supportsJS)
39+
|| (f.name.endsWith(".ts") && supportsJS)
40+
|| f.name.endsWith(".gjs")
41+
|| f.name.endsWith(".gts"))
42+
&& !f.name.endsWith(".d.ts")
3643
}
3744

3845
override fun annotate(input: JSLinterInput<TemplateLintState>): JSLinterAnnotationResult? {

src/main/kotlin/com/emberjs/hbs/linter/ember-template-lint/TemplateLintFixAction.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,15 @@ class TemplateLintFixAction : JSLinterFixAction(
6060
}
6161

6262
override fun isFileAccepted(project: Project, file: VirtualFile): Boolean {
63-
val f = PsiManager.getInstance(project).findFile(file)
64-
return f?.viewProvider is GtsFileViewProvider || f?.viewProvider is HbFileViewProvider || f is JSFile
63+
val f = PsiManager.getInstance(project).findFile(file) ?: return false
64+
val pkg = TemplateLintConfiguration.getInstance(project).extendedState.state.templateLintPackage
65+
val supportsJS = pkg.version?.let { it.major < 8 } ?: false
66+
return (f.name.endsWith(".hbs")
67+
|| (f.name.endsWith(".js") && supportsJS)
68+
|| (f.name.endsWith(".ts") && supportsJS)
69+
|| f.name.endsWith(".gjs")
70+
|| f.name.endsWith(".gts"))
71+
&& !f.name.endsWith(".d.ts")
6572
}
6673

6774
private fun fixFile(psiFile: PsiFile) {

0 commit comments

Comments
 (0)