Skip to content

Commit

Permalink
Skip processing angular and svelte files (prettier#160)
Browse files Browse the repository at this point in the history
prettier already takes care of formating these whole files, so skip
them, just like js/markdown/html/vue files
  • Loading branch information
BPScott authored and himanshiLt committed Apr 25, 2022
1 parent 71a5e9f commit 4663825
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 3 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@
"eslint-plugin-prettier": "^3.1.1",
"jest": "^24.9.0",
"prettier": "^1.19.1",
"prettier-plugin-svelte": "^2.1.6",
"strip-ansi": "^6.0.0",
"stylelint": "^9.5.0",
"stylelint-config-prettier": "^7.0.0"
"stylelint-config-prettier": "^7.0.0",
"svelte": "^3.34.0"
},
"engines": {
"node": ">=6"
Expand Down
2 changes: 2 additions & 0 deletions stylelint-prettier.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ module.exports = stylelint.createPlugin(
'vue',
'markdown',
'html',
'angular', // .component.html files
'svelte',
];
if (parserBlockList.indexOf(prettierFileInfo.inferredParser) !== -1) {
return;
Expand Down
16 changes: 16 additions & 0 deletions test/fixtures/check.inert.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<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>
12 changes: 12 additions & 0 deletions test/fixtures/check.inert.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<span>Hi</span>

<style lang="scss">
.foo {
background-image: url("x")
}
$map: (
'alpha': 10,
'beta': 20,
'gamma': 30
)
</style>
4 changes: 2 additions & 2 deletions test/stylelint-prettier-e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ check.invalid.scss
* Don't act upon html-like files, as prettier already handles them as whole
* files
*/
test('HTML/Markdown/Vue files', () => {
const result = runStylelint('*.{html,md,vue}');
test('HTML/Markdown/Vue/Svelte files', () => {
const result = runStylelint('*.{html,md,vue,svelte}');

const expectedResult = ``;

Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3561,6 +3561,11 @@ prettier-linter-helpers@^1.0.0:
dependencies:
fast-diff "^1.1.2"

prettier-plugin-svelte@^2.1.6:
version "2.1.6"
resolved "https://registry.yarnpkg.com/prettier-plugin-svelte/-/prettier-plugin-svelte-2.1.6.tgz#ae10e16d89c94c72a937574eb840501104ff4565"
integrity sha512-eg6MhH394IYsljIcLMgCx/wozObkUFZJ1GkH+Nj8sZQilnNCFTeSBcEohBaNa9hr5RExvlJQJ8a2CEjMMrwL8g==

prettier@^1.19.1:
version "1.19.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
Expand Down Expand Up @@ -4333,6 +4338,11 @@ supports-color@^6.1.0:
dependencies:
has-flag "^3.0.0"

svelte@^3.34.0:
version "3.34.0"
resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.34.0.tgz#a0195a0db0305d78df87520711317b99e6fb8a26"
integrity sha512-xWcaQ/J4Yd5k0UWz+ef6i5RW5WP3hNpluEI2qtTTKlMOXERHpVL509O9lIw7sgEn1JjJgTOS+lnnDj99vQ3YqQ==

svg-tags@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/svg-tags/-/svg-tags-1.0.0.tgz#58f71cee3bd519b59d4b2a843b6c7de64ac04764"
Expand Down

0 comments on commit 4663825

Please sign in to comment.