-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat: support svelte
(prettier-plugin-svelte
) and angular
parser
#156
Changes from all commits
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
package.json | ||
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. Why does this need to be removed? I would expect that the format of package.json is automatically handled by yarn/npm rather than being something that prettier needs to be concerned about |
||
test/fixtures | ||
|
||
# this file doesn't exist, but we use it as a filename that should be ignored | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,14 @@ | |
"arrowParens": "always", | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"bracketSpacing": false | ||
"bracketSpacing": false, | ||
"endOfLine": "auto", | ||
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 can be removed, thanks to the more targeted fix in #158 |
||
"overrides": [ | ||
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. By naming our fixture file |
||
{ | ||
"files": "*.angular.html", | ||
"options": { | ||
"parser": "angular" | ||
} | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
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. https://github.com/prettier/prettier/blob/ce26805e84756953875f30a0c165bd6b09c94ea0/src/language-html/index.js#L13 suggests that you can trigger the angular parser by using the If we name this file |
||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Page Title</title> | ||
<style> | ||
.foo { | ||
background-image: url('x'); | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<p class="mb-0" style="font-size: 12px; background-color: red">Hi</p> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<span>Hi</span> | ||
|
||
<style lang="scss"> | ||
.foo { | ||
background-image: url("x") | ||
} | ||
|
||
$map: ( | ||
'alpha': 10, | ||
'beta': 20, | ||
'gamma': 30 | ||
) | ||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"singleQuote": false, | ||
"tabWidth": 4, | ||
"trailingComma": "all" | ||
"trailingComma": "all", | ||
"endOfLine": "auto" | ||
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 can be removed, thanks to the more targeted fix in #158 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "es5", | ||
"endOfLine": "auto", | ||
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 can be removed, thanks to the more targeted fix in #158 |
||
"overrides": [ | ||
{ | ||
"files": "*.wxss", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,22 @@ const {resolve} = require('path'); | |
const stripAnsi = require('strip-ansi'); | ||
|
||
describe('E2E Tests', () => { | ||
test('CSS/SCSS files', () => { | ||
const result = runStylelint('*.{css,scss}'); | ||
test('CSS files', () => { | ||
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. I don't know why, but the order of the result are reversed sometimes, so I split the two type of files. 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. Huh, that is annoying. I've addressed this separately so this PR can focus on the svelte change: #159 Rebase atop latest master and you should be able to remove this. |
||
const result = runStylelint('*.css'); | ||
|
||
const expectedResult = ` | ||
check.invalid.css | ||
2:25 ✖ Replace ""x"" with "'x'" prettier/prettier | ||
`.trim(); | ||
|
||
expect(result.output).toEqual(expectedResult); | ||
expect(result.status).toEqual(2); | ||
}); | ||
|
||
test('SCSS files', () => { | ||
const result = runStylelint('*.scss'); | ||
|
||
const expectedResult = ` | ||
check.invalid.scss | ||
2:25 ✖ Replace ""x"" with "'x'" prettier/prettier | ||
8:14 ✖ Insert "," prettier/prettier | ||
|
@@ -39,6 +48,15 @@ check.invalid.scss | |
expect(result.output).toEqual(expectedResult); | ||
expect(result.status).toEqual(0); | ||
}); | ||
|
||
test('Svelte files', () => { | ||
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. Svelte files get treated the same as HTML/Markdown/Vue files in that they are inert. Rather than add a new test case just for Svelte, let's add them to the existing "HTML/Markdown/Vue files" test case by updating the name and changing like 23 to be |
||
const result = runStylelint('*.svelte'); | ||
|
||
const expectedResult = ``; | ||
|
||
expect(result.output).toEqual(expectedResult); | ||
expect(result.status).toEqual(0); | ||
}); | ||
}); | ||
|
||
function runStylelint(pattern) { | ||
|
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.
I've split this out into a separate commit in #158, where I add Prettier to the test matrix and perform a more targeted fix for the "endOfLine" stuff.
Rebase and you should be able to remove the changes to this file, and all instances where you add
"endOfLine": "auto"
to configs.