-
Notifications
You must be signed in to change notification settings - Fork 41
Use broader template-lint range #418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
035923e
514ae2f
1859807
2dd183c
827faef
10a09db
e2804b1
5e964ca
372197b
95e33c8
8b30ec5
e44d324
45158a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import Server from './server'; | |
| import { Project } from './project'; | ||
| import { getRequireSupport } from './utils/layout-helpers'; | ||
| import { getFileRanges, RangeWalker } from './utils/glimmer-script'; | ||
| import semver, { SemVer } from 'semver'; | ||
|
|
||
| type FindUp = (name: string, opts: { cwd: string; type: string }) => Promise<string | undefined>; | ||
| type LinterVerifyArgs = { source: string; moduleId: string; filePath: string }; | ||
|
|
@@ -88,7 +89,7 @@ export default class TemplateLinter { | |
| return this.server.projectRoots.projectForUri(textDocument.uri); | ||
| } | ||
|
|
||
| private sourcesForDocument(textDocument: TextDocument, templateLintVersion: string): string[] { | ||
| private sourcesForDocument(textDocument: TextDocument, templateLintVersion: SemVer | null): string[] { | ||
| const ext = getExtension(textDocument); | ||
|
|
||
| if (ext !== null && !extensionsToLint.includes(ext)) { | ||
|
|
@@ -98,8 +99,11 @@ export default class TemplateLinter { | |
| const documentContent = textDocument.getText(); | ||
|
|
||
| // we assume that ember-template-lint v5 could handle js/ts/gts/gjs files | ||
| if (!templateLintVersion) { | ||
| return [documentContent]; | ||
| } | ||
|
|
||
| if (templateLintVersion >= '5') { | ||
| if (semver.gte(templateLintVersion, '5.0.0')) { | ||
| return [documentContent]; | ||
| } | ||
|
Comment on lines
+107
to
109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't work sadly. semver.gte(semver.minVersion(templateLintVersion)?.version ?? '0.0.0', '5.0.0') |
||
|
|
||
|
|
@@ -152,11 +156,12 @@ export default class TemplateLinter { | |
| } | ||
|
|
||
| const linterMeta = project.dependenciesMeta.find((dep) => dep.name === 'ember-template-lint'); | ||
| const linterVersion = linterMeta?.version.split('.')[0] || 'unknown'; | ||
|
|
||
| let sources = []; | ||
|
|
||
| try { | ||
| const linterVersion = linterMeta?.version ? semver.parse(linterMeta.version) : null; | ||
lifeart marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| sources = this.sourcesForDocument(textDocument, linterVersion); | ||
| } catch (e) { | ||
| return; | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, it's extra bundle size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, my bad, we already have it in layout helpers, we good in this case.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it seems we don't need it anyway for our case
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lifeart why not? The raw string
^5.13.0for example can't be read asversionString[0]otherwise you get a version^no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arthur5005 it's not a case, we already cleaning value here: https://github.com/ember-tooling/ember-language-server/blob/master/src/utils/layout-helpers.ts#L293
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lifeart just tested how
cleanworks, I think it doesn't work how we think it's supposed to work, unless I'm missing something.I might not know how the package strings pre-processed though before reaching the clean method.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arthur5005 oh my, thank you for pointing to it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^- @NullVoxPopuli To @lifeart's point, I think how we parse dependency versions is the real problem here, I'm imagining the version on the dep meta is null for all unpinned projects. :\