Gathering detailed insights and metrics for eslint-plugin-prettier
Gathering detailed insights and metrics for eslint-plugin-prettier
Gathering detailed insights and metrics for eslint-plugin-prettier
Gathering detailed insights and metrics for eslint-plugin-prettier
@types/eslint-plugin-prettier
TypeScript definitions for eslint-plugin-prettier
@cailiao/eslint-plugin-prettier
eslint-plugin-prettier
eslint-plugin-prettier-vue
ESLint plugin for Prettier formatting, which is better for Vue SFC
@typescript-eslint/eslint-plugin
TypeScript plugin for ESLint
npm install eslint-plugin-prettier
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3,346 Stars
301 Commits
187 Forks
23 Watching
6 Branches
56 Contributors
Updated on 26 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-5%
3,407,323
Compared to previous day
Last week
3.8%
18,407,064
Compared to previous week
Last month
18.7%
73,574,846
Compared to previous month
Last year
23.4%
721,081,821
Compared to previous year
2
4
32
Runs Prettier as an ESLint rule and reports differences as individual ESLint issues.
If your desired formatting does not match Prettier’s output, you should use a different tool such as prettier-eslint instead.
Please read Integrating with linters before installing.
.eslintrc*
)eslint.config.js
)Svelte
supportarrow-body-style
and prefer-arrow-callback
issue1error: Insert `,` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.js:22:25: 2 20 | import { 3 21 | observeActiveEditorsDebounced, 4> 22 | editorChangesDebounced 5 | ^ 6 23 | } from './debounced';; 7 24 | 8 25 | import {observableFromSubscribeFunction} from '../commons-node/event'; 9 10 11error: Delete `;` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.js:23:21: 12 21 | observeActiveEditorsDebounced, 13 22 | editorChangesDebounced 14> 23 | } from './debounced';; 15 | ^ 16 24 | 17 25 | import {observableFromSubscribeFunction} from '../commons-node/event'; 18 26 | import {cacheWhileSubscribed} from '../commons-node/observable'; 19 20 212 errors found.
./node_modules/.bin/eslint --format codeframe pkg/commons-atom/ActiveEditorRegistry.js
(code from nuclide).
1npm install --save-dev eslint-plugin-prettier eslint-config-prettier 2npm install --save-dev --save-exact prettier
eslint-plugin-prettier
does not install Prettier or ESLint for you. You must install these yourself.
This plugin works best if you disable all other ESLint rules relating to code formatting, and only enable rules that detect potential bugs. If another active ESLint rule disagrees with prettier
about how code should be formatted, it will be impossible to avoid lint errors. Our recommended configuration automatically enables eslint-config-prettier
to disable all formatting-related ESLint rules.
.eslintrc*
)For legacy configuration, this plugin ships with a plugin:prettier/recommended
config that sets up both eslint-plugin-prettier
and eslint-config-prettier
in one go.
Add plugin:prettier/recommended
as the last item in the extends array in your .eslintrc*
config file, so that eslint-config-prettier
has the opportunity to override other configs:
1{ 2 "extends": ["plugin:prettier/recommended"] 3}
This will:
prettier/prettier
rule.arrow-body-style
and prefer-arrow-callback
rules which are problematic with this plugin - see the below for why.eslint-config-prettier
config which will turn off ESLint rules that conflict with Prettier.eslint.config.js
)For flat configuration, this plugin ships with an eslint-plugin-prettier/recommended
config that sets up both eslint-plugin-prettier
and eslint-config-prettier
in one go.
Import eslint-plugin-prettier/recommended
and add it as the last item in the configuration array in your eslint.config.js
file so that eslint-config-prettier
has the opportunity to override other configs:
1const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended'); 2 3module.exports = [ 4 // Any other config imports go at the top 5 eslintPluginPrettierRecommended, 6];
This will:
prettier/prettier
rule.arrow-body-style
and prefer-arrow-callback
rules which are problematic with this plugin - see the below for why.eslint-config-prettier
config which will turn off ESLint rules that conflict with Prettier.Svelte
supportWe recommend to use eslint-plugin-svelte
instead of eslint-plugin-svelte3
because eslint-plugin-svelte
has a correct eslint-svelte-parser
instead of hacking.
When use with eslint-plugin-svelte3
, eslint-plugin-prettier
will just ignore the text passed by eslint-plugin-svelte3
, because the text has been modified.
If you still decide to use eslint-plugin-svelte3
, you'll need to run prettier --write *.svelte
manually.
arrow-body-style
and prefer-arrow-callback
issueIf you use arrow-body-style or prefer-arrow-callback together with the prettier/prettier
rule from this plugin, you can in some cases end up with invalid code due to a bug in ESLint’s autofix – see issue #65.
For this reason, it’s recommended to turn off these rules. The plugin:prettier/recommended
config does that for you.
You can still use these rules together with this plugin if you want, because the bug does not occur all the time. But if you do, you need to keep in mind that you might end up with invalid code, where you manually have to insert a missing closing parenthesis to get going again.
If you’re fixing large of amounts of previously unformatted code, consider temporarily disabling the prettier/prettier
rule and running eslint --fix
and prettier --write
separately.
Note: While it is possible to pass options to Prettier via your ESLint configuration file, it is not recommended because editor extensions such as
prettier-atom
andprettier-vscode
will read.prettierrc
, but won't read settings from ESLint, which can lead to an inconsistent experience.
The first option:
An object representing options that will be passed into prettier. Example:
1{ 2 "prettier/prettier": [ 3 "error", 4 { 5 "singleQuote": true, 6 "parser": "flow" 7 } 8 ] 9}
NB: This option will merge and override any config set with .prettierrc
files
The second option:
An object with the following options
usePrettierrc
: Enables loading of the Prettier configuration file, (default: true
). May be useful if you are using multiple tools that conflict with each other, or do not wish to mix your ESLint settings with your Prettier configuration. And also, it is possible to run prettier without loading the prettierrc config file via the CLI's --no-config option or through the API by calling prettier.format() without passing through the options generated by calling resolveConfig.
1{ 2 "prettier/prettier": [ 3 "error", 4 {}, 5 { 6 "usePrettierrc": false 7 } 8 ] 9}
fileInfoOptions
: Options that are passed to prettier.getFileInfo to decide whether a file needs to be formatted. Can be used for example to opt-out from ignoring files located in node_modules
directories.
1{ 2 "prettier/prettier": [ 3 "error", 4 {}, 5 { 6 "fileInfoOptions": { 7 "withNodeModules": true 8 } 9 } 10 ] 11}
The rule is auto fixable -- if you run eslint
with the --fix
flag, your code will be formatted according to prettier
style.
@prettier/plugin-eslint | eslint-config-prettier | eslint-plugin-prettier | prettier-eslint | prettier-eslint-cli |
---|---|---|---|---|
@prettier/plugin-eslint | eslint-config-prettier | eslint-plugin-prettier | prettier-eslint | prettier-eslint-cli |
---|---|---|---|---|
See CONTRIBUTING.md
Detailed changes for each release are documented in CHANGELOG.md.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
4 existing vulnerabilities detected
Details
Reason
2 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 5
Reason
Found 7/18 approved changesets -- score normalized to 3
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More