Repository navigation
Description
What version of eslint are you using?
8.55.0
What version of prettier are you using?
3.1.0
What version of eslint-plugin-prettier are you using?
5.0.1
Please paste any applicable config files that you're using (e.g. .prettierrc or .eslintrc files)
.prettierrc
{
"tabWidth": 2,
"printWidth": 100,
"singleQuote": true,
"semi": false,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"plugins": ["@prettier/plugin-pug"],
"pugSortAttributes": "asc"
}
.eslintrc.json
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:prettier/recommended"
],
"plugins": [
"pug"
],
"parserOptions": {
"ecmaVersion": "latest"
}
}
What source code are you linting?
The plugin is working incorrectly in the files that use template pug (jade).
In the other files (like js) it is working correctly.
What did you expect to happen?
Report errors using the command eslint file.pug and highlight errors in the editor (VS Code).
What actually happened?
The errors are not highlighted in the editor but when I save the file is automatically formatted correctly using prettier.
The command eslint doesn't return any errors:
> eslint file.pug
npm timing command:run Completed in 202ms
npm verb exit 0
npm timing npm Completed in 223ms
npm info ok
But the command prettier report some errors:
> prettier file.pug --check
Checking formatting... : timing npm:load Completed in 18ms
[warn] file.pug
[warn] Code style issues found in the above file. Run Prettier to fix.
npm timing command:run Completed in 182ms
npm verb exit 1
npm timing npm Completed in 203ms
npm verb code 1
Steps to reproduce
You can find an example at this link: https://codesandbox.io/p/devbox/quizzical-joana-zlpzn8
Javascript working as expected:
- Run
npm run prettier:js-> errors are found - Run
npm run lint:js-> errors from prettier are reported
Pug not working:
- Run
npm run prettier:pug-> errors are found - Run
npm run lint:js-> no errors reported
Activity
JounQin commentedon Dec 4, 2023
We need runnable reproduction like codesandbox, GitHub Repository, etc. Not just codes.
enrico-hic commentedon Dec 4, 2023
I have added the sandbox to the issue description. As it's my first time with codesandbox, I hope it is configured correctly, if not please let me know.
JounQin commentedon Dec 4, 2023
I'll take a look tomorrow.
JounQin commentedon Dec 19, 2023
I don't how run commands on your CodeSandbox, but indeed,
eslint-plugin-pugis not supported at all in this plugin.JounQin commentedon Dec 19, 2023
eslint-plugin-pugis an ESLint plugin which only check inline scripts, not the whole file. So we don't have the chance to format the whole pug file at all.So for pug files, you need to run
prettiermanually instead relying on this plugin.However, there is still an area that we can improve that there is no need format the inline scripts inside pug.
chore: skip formatting inline scripts in pug files
chore: skip formatting inline scripts in pug files
chore: skip formatting inline scripts in pug files (#619)