-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lint rule for implicit
is:inline
on script tags. (#970)
* add lint for implicit is:inline on script tags * add changeset * adjust exisitng test * add test * remove unused args * Apply suggestions from code review Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> * Apply suggestions from code review Co-authored-by: Happydev <81974850+MoustaphaDev@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Happydev <81974850+MoustaphaDev@users.noreply.github.com> * update test: `NPM` -> `npm` * exclude external scripts from the diagnsotic * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * shorten the lint message * comma * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> --------- Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> Co-authored-by: Happydev <81974850+MoustaphaDev@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
- Loading branch information
1 parent
a90d99e
commit 86221d6
Showing
5 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/compiler': patch | ||
--- | ||
|
||
Adds a lint rule to display a message when attributes are added to a script tag, explaining that the script will be treated as `is:inline`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { test } from 'uvu'; | ||
import * as assert from 'uvu/assert'; | ||
import { transform } from '@astrojs/compiler'; | ||
|
||
test('reports a hint for adding attributes to a script tag without is:inline', async () => { | ||
const result = await transform(`<script type="module"></script>`); | ||
assert.equal(result.diagnostics[0].severity, 4); | ||
assert.match(result.diagnostics[0].text, /\#script-processing/); | ||
}); | ||
|
||
test('does not report a diagnostic for the src attribute', async () => { | ||
const result = await transform(`<script src="/external.js"></script>`); | ||
console.log(result.diagnostics) | ||
assert.equal(result.diagnostics.length, 0); | ||
}); | ||
|
||
test.run(); |