Skip to content

Commit

Permalink
chore: skip formatting inline scripts in pug files (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Dec 21, 2023
1 parent 183f45c commit b5c0dc5
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-sheep-doubt.md
@@ -0,0 +1,5 @@
---
'eslint-plugin-prettier': patch
---

chore: skip formatting inline scripts in pug files
2 changes: 1 addition & 1 deletion .prettierrc
@@ -1,5 +1,5 @@
{
"arrowParens": "avoid",
"singleQuote": true,
"plugins": ["prettier-plugin-pkg"]
"plugins": ["@prettier/plugin-pug", "prettier-plugin-pkg"]
}
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -63,6 +63,7 @@
"@eslint-community/eslint-plugin-eslint-comments": "^4.1.0",
"@eslint/js": "^8.55.0",
"@graphql-eslint/eslint-plugin": "^3.20.0",
"@prettier/plugin-pug": "^3.0.0",
"@types/eslint": "^8.44.7",
"@types/prettier-linter-helpers": "^1.0.1",
"commitlint": "^18.4.3",
Expand All @@ -74,6 +75,7 @@
"eslint-plugin-mdx": "^2.2.0",
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-prettier": "link:.",
"eslint-plugin-pug": "^1.2.5",
"eslint-plugin-svelte": "^2.32.2",
"eslint-plugin-svelte3": "^4.0.0",
"graphql": "^16.7.1",
Expand Down
110 changes: 99 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/fixtures/pug.pug
@@ -0,0 +1,2 @@
script.
a();;;;;;
10 changes: 10 additions & 0 deletions test/prettier.js
Expand Up @@ -59,6 +59,10 @@ const eslint = new ESLint({
files: '**/eslint-plugin-svelte/*.svelte',
extends: ['plugin:svelte/recommended'],
},
{
files: '*.pug',
plugins: ['pug'],
},
],
},
useEslintrc: false,
Expand Down Expand Up @@ -306,6 +310,12 @@ runFixture(
true,
);

/**
* The `script` code style actually does not match `prettier`'s,
* but we are skipping scripts in pug files
*/
runFixture('*.pug', [[]]);

// ------------------------------------------------------------------------------
// Helpers
// ------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions worker.js
Expand Up @@ -145,6 +145,7 @@ runAsWorker(
'mdx',
'angular',
'svelte',
'pug',
];
if (parserBlocklist.includes(/** @type {string} */ (inferredParser))) {
return;
Expand Down

0 comments on commit b5c0dc5

Please sign in to comment.