first commit

This commit is contained in:
jefferyzhao
2025-07-31 17:44:12 +08:00
commit b9bdc8598b
42390 changed files with 4467935 additions and 0 deletions

View File

@ -0,0 +1,21 @@
"use strict";
module.exports = {
rules: {
"@typescript-eslint/quotes": 0,
"@typescript-eslint/brace-style": "off",
"@typescript-eslint/comma-dangle": "off",
"@typescript-eslint/comma-spacing": "off",
"@typescript-eslint/func-call-spacing": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/keyword-spacing": "off",
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/no-extra-parens": "off",
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/semi": "off",
"@typescript-eslint/space-before-function-paren": "off",
"@typescript-eslint/space-infix-ops": "off",
"@typescript-eslint/type-annotation-spacing": "off",
},
};

360
node_modules/eslint-config-prettier/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,360 @@
### Version 6.15.0 (2020-10-27)
- Added: [@typescript-eslint/space-infix-ops]. Thanks to Masafumi Koba (@ybiquitous)!!
### Version 6.14.0 (2020-10-21)
- Added: New [eslint-plugin-vue] rules: [vue/array-bracket-newline] and [vue/block-tag-newline]. Thanks to @xcatliu!
### Version 6.13.0 (2020-10-16)
- Added: New rules in [eslint-plugin-vue] 7.0 (which supports Vue 3.0). Thanks to @xcatliu!
### Version 6.12.0 (2020-09-25)
- Added: [@typescript-eslint/comma-dangle]. Thanks to Masafumi Koba (@ybiquitous)!!
### Version 6.11.0 (2020-04-21)
- Added: [@typescript-eslint/keyword-spacing]. Thanks to Hans Bergren (@hbergren)!
### Version 6.10.1 (2020-03-22)
- Improved: Recommend using `npx` when running the CLI helper tool.
- Updated: Mention that eslint-config-prettier has been tested with Prettier 2.0 and the latest versions of plugins.
### Version 6.10.0 (2020-01-28)
- Added: [@typescript-eslint/comma-spacing]. Thanks to Masafumi Koba (@ybiquitous)!!
### Version 6.9.0 (2019-12-27)
- Added: [vue/max-len]. Thanks to @xcatliu!
### Version 6.8.0 (2019-12-25)
- Added: [@typescript-eslint/no-extra-semi]. Thanks to @xcatliu!
### Version 6.7.0 (2019-11-19)
- Added: [@typescript-eslint/space-before-function-paren]. Thanks to Masafumi Koba (@ybiquitous)!
### Version 6.6.0 (2019-11-17)
- Added: New [eslint-plugin-vue] rules: [vue/dot-location] and [vue/keyword-spacing]. Thanks to @xcatliu!
### Version 6.5.0 (2019-10-26)
- Added: Support for [excluding deprecated rules]. Thanks to Alex Ilyaev (@alexilyaev)!
### Version 6.4.0 (2019-10-05)
- Added: [unicorn/no-nested-ternary]. Thanks to Yang Mingshan (@yangmingshan)!
### Version 6.3.0 (2019-09-10)
- Added: [@typescript-eslint/brace-style]. Thanks to Masafumi Koba (@ybiquitous)!
### Version 6.2.0 (2019-09-03)
- Added: [@typescript-eslint/quotes] (as a [special rule][@typescript-eslint/quotes-special]). Thanks to Masafumi Koba (@ybiquitous)!
### Version 6.1.0 (2019-08-19)
- Added: [function-call-argument-newline] \(new in ESLint 6.2.0). Thanks to Masafumi Koba (@ybiquitous)!
### Version 6.0.0 (2019-06-25)
- Changed: The CLI helper tool now considers [no-confusing-arrow] to conflict if you use the default value of its `allowParens` option. The default was changed to `true` in ESLint 6, which conflicts with Prettier.
If the CLI helper tool gives you errors about this after upgrading, the solution is to change this:
```json
{
"rules": {
"no-confusing-arrow": ["error"]
}
}
```
Into this:
```json
{
"rules": {
"no-confusing-arrow": ["error", { "allowParens": false }]
}
}
```
The latter works in both ESLint 6 as well as in ESLint 5 and older.
- Improved: `eslint --print-config` usage instructions. The CLI tool help text as well as the documentation has been updated to suggest commands that work in ESLint 6.0 as well as in ESLint 5 and older. (Instead of `eslint --print-config .`, use `eslint --print-config path/to/main.js`.)
### Version 5.1.0 (2019-06-25)
- Added: [react/jsx-curly-newline]. Thanks to Masafumi Koba (@ybiquitous)!
### Version 5.0.0 (2019-06-15)
- Removed: [react/self-closing-comp]. This rule was added in v4.1.0 not because it _conflicted_ with Prettier but because it was _unnecessary_ when using Prettier. However, in v1.18.0 [Prettier stopped converting empty elements to self-closing elements][prettier-self-closing]. So the rule is not unnecessary anymore.
If you use Prettier v1.17.1 or older you should be able to upgrade eslint-config-prettier to v5.0.0 without having to do anything else.
If you use Prettier v1.18.0 or newer, you might get lint errors about for example changing `<div></div>` into `<div />`. You have two options:
- Run `eslint --fix` if you prefer to enforce self-closing elements where possible. This should fix all the errors.
- Add `"react/self-closing-comp": "off"` to your ESLint config if you use autofix from your editor and you face the same [issue as Prettier did][prettier-self-closing].
- Changed: Node.js 6 is no longer officially supported, but v5.0.0 should still work with it.
### Version 4.3.0 (2019-05-16)
- Added: New [eslint-plugin-vue] rules: [vue/arrow-spacing], [vue/block-spacing], [vue/brace-style] and [vue/comma-dangle].
- Added: New [@typescript-eslint/eslint-plugin] rules: [@typescript-eslint/func-call-spacing] and [@typescript-eslint/semi].
### Version 4.2.0 (2019-04-25)
- Added: [@typescript-eslint/no-extra-parens]. Thanks to Keiichiro Amemiya (@Hoishin) and Jen Gorfine (@jgorfine)!
### Version 4.1.0 (2019-02-26)
- Added: [linebreak-style]. Use Prettiers [end-of-line] option instead.
- Added: [react/self-closing-comp]. Thanks to Gaurav Gupta (@gaurav5430)!
### Version 4.0.0 (2019-01-26)
- Breaking change: Support for [eslint-plugin-typescript] has been removed and replaced with support for its successor [@typescript-eslint/eslint-plugin]. Thanks to TANIGUCHI Masaya (@ta2gch) and everyone else who helped with this!
- Changed: [arrow-body-style] and [prefer-arrow-callback] are now marked as [special rules][arrow-special], since they might cause problems if using [eslint-plugin-prettier] and `--fix`. They are turned off by default, and the CLI helper tool will _warn_ about them (but not error if you do enable them). This wont break your linting checks, but do note that these rules will be disabled unless you explicitly enable them again, and that you might see new warnings when running the CLI helper tool.
### Version 3.6.0 (2019-01-19)
- Added: Support for [eslint-plugin-babel]. Thanks to Matija Marohnić (@silvenon)!
### Version 3.5.0 (2019-01-16)
- Fixed: The eslint-plugin-vue change from 3.4.0 has been reverted. That change requires eslint-plugin-vue@5, while many use eslint-plugin-vue@4. In other words, it was an accidental breaking change. Also, after thinking about it some more, it makes sense to have a Prettier-specific list of rules, rather than using the `vue/no-layout-rules` list, since there can be layout rules that dont conflict with but rather complement Prettier.
- Added: New eslint-plugin-vue rules coming in the next version after 5.1.0.
### Version 3.4.0 (2019-01-13)
- Added: Support for [eslint-plugin-typescript]. Thanks to Jed Fox (@j-f1)!
- Improved: The eslint-plugin-vue integration is now using the `vue/no-layout-rules` config behind the scenes, so it should automatically stay up-to-date when new eslint-plugin-vue versions are released. Thanks to Michał Sajnóg (@michalsnik)!
### Version 3.3.0 (2018-11-11)
- Added: The [vue/html-self-closing] rule (as a [special rule][vue/html-self-closing-special]). Thanks to Yamagishi Kazutoshi (@ykzts)!
### Version 3.2.0 (2018-11-10)
- Added: Support for [eslint-plugin-vue].
- Fixed: The CLI helper tool should now work in Node.js 6 with npm 3 again. Thanks to Grant Snodgrass (@meeber)!
- Improved: Updated documentation.
### Version 3.1.0 (2018-09-22)
- Added: Support for [eslint-plugin-unicorn]. Thanks to John Mars (@j0hnm4r5)!
- Changed: The [quotes] rule is now allowed to be used to forbid unnecessary backticks. This means that the CLI helper tool no longer can automatically validate it, so youll need to refer the [quotes special rule documentation][quotes-special]. Thanks to Nick Petruzzelli (@npetruzzelli)!
### Version 3.0.1 (2018-08-13)
- Improved: `eslint --print-config` usage instructions.
### Version 3.0.0 (2018-08-13)
- Breaking change: Dropped Node.js 4 support.
### Version 2.10.0 (2018-08-13)
- Added: [flowtype/boolean-style]. Thanks to Mayank Agarwal (@Mayank1791989)!
- Added: [react/jsx-child-element-spacing]
- Added: [react/jsx-props-no-multi-spaces]
### Version 2.9.0 (2017-11-26)
- Added: The [implicit-arrow-linebreak] rule.
### Version 2.8.0 (2017-11-19)
- Added: The [react/jsx-one-expression-per-line] rule.
### Version 2.7.0 (2017-11-01)
- Added: The [lines-around-comment] rule (as a [special rule][lines-around-comment-special]). Thanks to Maurice de Beijer (@mauricedb)!
- Added: The [no-unexpected-multiline] rule (as a [special rule][no-unexpected-multiline-special]). Thanks to Suhas Karanth (@sudo-suhas)!
### Version 2.6.0 (2017-09-23)
- Added: The [no-floating-decimal] rule.
### Version 2.5.0 (2017-09-16)
- Added: Support for [eslint-plugin-standard]. Thanks to Christian Pekeler (@pekeler)!
### Version 2.4.0 (2017-09-02)
- Added: The [function-paren-newline] rule (new in [ESLint 4.6.0]). Thanks to Pierre Vanduynslager (@vanduynslagerp)!
### Version 2.3.0 (2017-06-30)
- Added: The (deprecated) [indent-legacy] rule. Thanks to M. Ian Graham (@miangraham)!
### Version 2.2.0 (2017-06-17)
- Added: New rules from [ESLint 4.0.0]:
- [array-element-newline]
- [array-bracket-newline]
- [semi-style]
- [switch-colon-spacing]
- Added: [react/jsx-closing-tag-location]
### Version 2.1.1 (2017-05-20)
- No code changes. Just updates to the readme.
### Version 2.1.0 (2017-05-13)
- Added: The [no-tabs] rule (as a [special rule][no-tabs-special]). Thanks to Alex Meah (@AlexMeah)!
### Version 2.0.0 (2017-05-07)
- Changed/Improved: The CLI helper tool is now more helpful.
- The options of special rules are now validated if possible. If a special rule is enabled with non-conflicting options, the CLI no longer warns about it.
- If only special rules that cannot be automatically checked are found, the CLI no longer exists with a non-zero exit code. Instead, it only warns about the rules.
- Changed: The [no-confusing-arrow] is now a special rule again, since it might conflict with recent Prettier versions.
- Removed: The `react/wrap-multilines` rule (which has been deprecated for a while), since it was removed in eslint-plugin-react@7.
### Version 1.7.0 (2017-04-19)
- Changed: The [no-confusing-arrow] is no longer a special rule, but simply turned off, since recent Prettier versions make it redundant.
- Improved: The CLI helper tool now has a more helpful message for special rules, and exits with a different status code if only special rules were found. The exit codes are now documented as well.
### Version 1.6.0 (2017-04-05)
- Added: The [curly] rule. Thanks to Martin Rädlinger (@formatlos)!
### Version 1.5.0 (2017-03-04)
- Added: The [nonblock-statement-body-position] rule.
### Version 1.4.1 (2017-02-28)
- Improved: eslint-config-prettier is now part of the [prettier] organization! This version updates all URLs to point to the new home of the project.
### Version 1.4.0 (2017-02-26)
- Added: The [no-confusing-arrow] rule (as a [special rule][no-confusing-arrow-special]). Thanks to Dominik Ferber (@dferber90)!
- Added: Deprecated or removed rules that might conflict with prettier. Thanks to Dominik Ferber (@dferber90)!
### Version 1.3.0 (2017-02-21)
- Added: The [template-tag-spacing] rule. Thanks to Thibault Derousseaux (@tibdex)!
### Version 1.2.0 (2017-02-14)
- Added: The [one-var-declaration-per-line] rule. Thanks to Ruben Oostinga (@0xR)!
### Version 1.1.1 (2017-02-12)
- Minor documentation tweak: Changed "Exceptions" into "Special rules".
### Version 1.1.0 (2017-02-10)
- Fixed: The [eslint-plugin-react] exclusion rules now actually work.
- Fixed: The CLI helper tool now works in Node.js 4. Thanks to Nathan Friedly (@nfriedly)!
- Added: Support for [eslint-plugin-flowtype].
- Improved: Minor things for the CLI helper tool.
- Improved: There are now tests for everything.
### Version 1.0.3 (2017-02-03)
- Fixed: `"extends": "prettier/react"` now actually works.
### Version 1.0.2 (2017-01-30)
- Improved: CLI helper tool instructions.
### Version 1.0.1 (2017-01-29)
- No difference from 1.0.0. Just an `npm publish` mistake.
### Version 1.0.0 (2017-01-29)
- Initial release.
[@typescript-eslint/brace-style]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/brace-style.md
[@typescript-eslint/comma-dangle]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/comma-dangle.md
[@typescript-eslint/comma-spacing]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/comma-spacing.md
[@typescript-eslint/eslint-plugin]: https://github.com/typescript-eslint/typescript-eslint
[@typescript-eslint/func-call-spacing]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/func-call-spacing.md
[@typescript-eslint/keyword-spacing]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/keyword-spacing.md
[@typescript-eslint/no-extra-parens]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-parens.md
[@typescript-eslint/no-extra-semi]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-semi.md
[@typescript-eslint/quotes-special]: https://github.com/prettier/eslint-config-prettier/blob/857257179fe69715362dfa9300762d6e534c0603/README.md#quotes
[@typescript-eslint/quotes]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md
[@typescript-eslint/semi]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/semi.md
[@typescript-eslint/space-before-function-paren]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/space-before-function-paren.md
[@typescript-eslint/space-infix-ops]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/space-infix-ops.md
[array-bracket-newline]: https://eslint.org/docs/rules/array-bracket-newline
[array-element-newline]: https://eslint.org/docs/rules/array-element-newline
[arrow-body-style]: https://eslint.org/docs/rules/arrow-body-style
[arrow-special]: https://github.com/prettier/eslint-config-prettier/blob/2c842675e55b91aecaef6f997d234ebf2d220ffb/README.md#arrow-body-style-and-prefer-arrow-callback
[curly]: https://eslint.org/docs/rules/curly
[end-of-line]: https://prettier.io/docs/en/options.html#end-of-line
[eslint 4.0.0]: https://eslint.org/blog/2017/06/eslint-v4.0.0-released
[eslint 4.6.0]: https://eslint.org/blog/2017/09/eslint-v4.6.0-released
[eslint-plugin-babel]: https://github.com/babel/eslint-plugin-babel
[eslint-plugin-flowtype]: https://github.com/gajus/eslint-plugin-flowtype
[eslint-plugin-prettier]: https://github.com/prettier/eslint-plugin-prettier
[eslint-plugin-react]: https://github.com/yannickcr/eslint-plugin-react
[eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard
[eslint-plugin-typescript]: https://github.com/bradzacher/eslint-plugin-typescript
[eslint-plugin-unicorn]: https://github.com/sindresorhus/eslint-plugin-unicorn
[eslint-plugin-vue]: https://github.com/vuejs/eslint-plugin-vue
[excluding deprecated rules]: https://github.com/prettier/eslint-config-prettier/tree/9f6b59486ad742dc12ad3be157ddff5f8454ef7a#excluding-deprecated-rules
[flowtype/boolean-style]: https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-boolean-style
[function-call-argument-newline]: https://eslint.org/docs/rules/function-call-argument-newline
[function-paren-newline]: https://eslint.org/docs/rules/function-paren-newline
[implicit-arrow-linebreak]: https://eslint.org/docs/rules/implicit-arrow-linebreak
[indent-legacy]: https://eslint.org/docs/rules/indent-legacy
[linebreak-style]: https://eslint.org/docs/rules/linebreak-style
[lines-around-comment-special]: https://github.com/prettier/eslint-config-prettier/blob/5399175c37466747aae9d407021dffec2c169c8b/README.md#lines-around-comment
[lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment
[no-confusing-arrow-special]: https://github.com/prettier/eslint-config-prettier/blob/08ac5bcc25c9cdc71864b4a1e4191e7d28dd2bc2/README.md#no-confusing-arrow
[no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow
[no-floating-decimal]: https://eslint.org/docs/rules/no-floating-decimal
[no-tabs-special]: https://github.com/prettier/eslint-config-prettier/blob/dfa6e2b51f11a8001e9e7d38b78f03c7d75175ec/README.md#no-tabs
[no-tabs]: https://eslint.org/docs/rules/no-tabs
[no-unexpected-multiline-special]: https://github.com/prettier/eslint-config-prettier/blob/5399175c37466747aae9d407021dffec2c169c8b/README.md#no-unexpected-multiline
[no-unexpected-multiline]: https://eslint.org/docs/rules/no-unexpected-multiline
[nonblock-statement-body-position]: https://eslint.org/docs/rules/nonblock-statement-body-position
[one-var-declaration-per-line]: https://eslint.org/docs/rules/one-var-declaration-per-line
[prefer-arrow-callback]: https://eslint.org/docs/rules/prefer-arrow-callback
[prettier-self-closing]: https://prettier.io/blog/2019/06/06/1.18.0.html#stop-converting-empty-jsx-elements-to-self-closing-elements-6127-by-duailibe
[prettier]: https://github.com/prettier
[quotes-special]: https://github.com/prettier/eslint-config-prettier/blob/8d264cd0a7f06c12e2e05415e0282a4f8f21ebc9/README.md#quotes
[quotes]: https://eslint.org/docs/rules/quotes
[react/jsx-child-element-spacing]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md
[react/jsx-closing-tag-location]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
[react/jsx-curly-newline]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md
[react/jsx-one-expression-per-line]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
[react/jsx-props-no-multi-spaces]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md
[react/self-closing-comp]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
[semi-style]: https://eslint.org/docs/rules/semi-style
[switch-colon-spacing]: https://eslint.org/docs/rules/switch-colon-spacing
[template-tag-spacing]: https://eslint.org/docs/rules/template-tag-spacing
[unicorn/no-nested-ternary]: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/no-nested-ternary.md
[vue/arrow-spacing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/arrow-spacing.md
[vue/block-spacing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/block-spacing.md
[vue/brace-style]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/brace-style.md
[vue/comma-dangle]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/comma-dangle.md
[vue/dot-location]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/dot-location.md
[vue/html-self-closing-special]: https://github.com/prettier/eslint-config-prettier/blob/d5e7af986221df5faedc12893d8dc3150a808693/README.md#vuehtml-self-closing
[vue/html-self-closing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md
[vue/keyword-spacing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/keyword-spacing.md
[vue/keyword-spacing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/array-bracket-newline.md
[vue/keyword-spacing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/block-tag-newline.md
[vue/max-len]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/max-len.md

21
node_modules/eslint-config-prettier/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017, 2018, 2019 Simon Lydell and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

794
node_modules/eslint-config-prettier/README.md generated vendored Normal file
View File

@ -0,0 +1,794 @@
# eslint-config-prettier
Turns off all rules that are unnecessary or might conflict with [Prettier].
This lets you use your favorite shareable config without letting its stylistic choices get in the way when using Prettier.
Note that this config _only_ turns rules _off,_ so it only makes sense using it together with some other config.
## Contents
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [Installation](#installation)
- [Excluding deprecated rules](#excluding-deprecated-rules)
- [CLI helper tool](#cli-helper-tool)
- [Special rules](#special-rules)
- [arrow-body-style and prefer-arrow-callback](#arrow-body-style-and-prefer-arrow-callback)
- [curly](#curly)
- [lines-around-comment](#lines-around-comment)
- [max-len](#max-len)
- [no-confusing-arrow](#no-confusing-arrow)
- [no-mixed-operators](#no-mixed-operators)
- [no-tabs](#no-tabs)
- [no-unexpected-multiline](#no-unexpected-multiline)
- [quotes](#quotes)
- [Enforce backticks](#enforce-backticks)
- [Forbid unnecessary backticks](#forbid-unnecessary-backticks)
- [Example double quote configuration](#example-double-quote-configuration)
- [Example single quote configuration](#example-single-quote-configuration)
- [vue/html-self-closing](#vuehtml-self-closing)
- [Other rules worth mentioning](#other-rules-worth-mentioning)
- [no-sequences](#no-sequences)
- [Contributing](#contributing)
- [License](#license)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Installation
Install eslint-config-prettier:
```
npm install --save-dev eslint-config-prettier
```
Then, add eslint-config-prettier to the "extends" array in your `.eslintrc.*` file. Make sure to put it **last,** so it gets the chance to override other configs.
<!-- prettier-ignore -->
```json
{
"extends": [
"some-other-config-you-use",
"prettier"
]
}
```
A few ESLint plugins are supported as well:
- [@typescript-eslint/eslint-plugin]
- [eslint-plugin-babel]
- [eslint-plugin-flowtype]
- [eslint-plugin-react]
- [eslint-plugin-standard]
- [eslint-plugin-unicorn]
- [eslint-plugin-vue]
Add extra exclusions for the plugins you use like so:
<!-- prettier-ignore -->
```json
{
"extends": [
"some-other-config-you-use",
"prettier",
"prettier/@typescript-eslint",
"prettier/babel",
"prettier/flowtype",
"prettier/react",
"prettier/standard",
"prettier/unicorn",
"prettier/vue"
]
}
```
If you extend a config which uses a plugin, it is recommended to add `"prettier/that-plugin"` (if available). For example, [eslint-config-airbnb] enables [eslint-plugin-react] rules, so `"prettier/react"` is needed:
<!-- prettier-ignore -->
```json
{
"extends": [
"airbnb",
"prettier",
"prettier/react"
]
}
```
If youre unsure which plugins are used, you can usually find them in your `package.json`.
### Excluding deprecated rules
Some of the rules that eslint-config-prettier turns off may be deprecated. **This is perfectly fine,** but if you really need to omit the deprecated rules, you can do so by setting the `ESLINT_CONFIG_PRETTIER_NO_DEPRECATED` environment variable to a non-empty value. For example:
```
env ESLINT_CONFIG_PRETTIER_NO_DEPRECATED=true npx eslint-find-rules --deprecated index.js
```
## CLI helper tool
eslint-config-prettier also ships with a little CLI tool to help you check if your configuration contains any rules that are unnecessary or conflict with Prettier.
You can run it using `npx`:
```
npx eslint --print-config path/to/main.js | npx eslint-config-prettier-check
```
(Change `path/to/main.js` to a file that exists in your project.)
In theory you need to run `npx eslint --print-config file.js | npx eslint-config-prettier-check` for every single file in your project to be 100% sure that there are no conflicting rules, because ESLint supports having different rules for different files. But usually youll have about the same rules for all files, so it is enough to run the command on one file (pick one that you wont be moving). If you use [multiple configuration files] or [overrides], you can (but you probably dont need to!) run the above script several times with different `--print-config` arguments, such as:
```
npx eslint --print-config index.js | npx eslint-config-prettier-check
npx eslint --print-config test/index.js | npx eslint-config-prettier-check
npx eslint --print-config legacy/main.js | npx eslint-config-prettier-check
```
Exit codes:
- 0: No problems found.
- 1: Unexpected error.
- 2: Conflicting rules found.
## Special rules
There a few rules that eslint-config-prettier disables that actually can be enabled in some cases.
- Some require certain options. The CLI helper tool validates this.
- Some require special attention when writing code. The CLI helper tool warns you if any of those rules are enabled, but cant tell if anything is problematic.
- Some can cause problems if using [eslint-plugin-prettier] and `--fix`.
For maximum ease of use, the special rules are disabled by default. If you want them, you need to explicitly specify them in your ESLint config.
### [arrow-body-style] and [prefer-arrow-callback]
**These rules might cause problems if using [eslint-plugin-prettier] and `--fix`.**
If you use any of these rules together with the `prettier/prettier` rule from [eslint-plugin-prettier], you can in some cases end up with invalid code due to a bug in ESLints autofix.
These rules are safe to use if:
- You dont use [eslint-plugin-prettier]. In other words, you run `eslint --fix` and `prettier --write` as separate steps.
- You _do_ use [eslint-plugin-prettier], but dont use `--fix`. (But then, whats the point?)
You _can_ still use these rules together with [eslint-plugin-prettier] 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 youre fixing large of amounts of previously unformatted code, consider temporarily disabling the `prettier/prettier` rule and running `eslint --fix` and `prettier --write` separately.
See these issues for more information:
- [eslint-config-prettier#31]
- [eslint-config-prettier#71]
- [eslint-plugin-prettier#65]
When the autofix bug in ESLint has been fixed, the special case for these rules can be removed.
### [curly]
**This rule requires certain options.**
If a block (for example after `if`, `else`, `for` or `while`) contains only one statement, JavaScript allows omitting the curly braces around that statement. This rule enforces if or when those optional curly braces should be omitted.
If you use the `"multi-line"` or `"multi-or-nest"` option, the rule can conflict with Prettier.
For example, the `"multi-line"` option allows this line:
<!-- prettier-ignore -->
```js
if (cart.items && cart.items[0] && cart.items[0].quantity === 0) updateCart(cart);
```
However, Prettier might consider the line too long and turn it into the following, which the `"multi-line"` option does _not_ allow:
<!-- prettier-ignore -->
```js
if (cart.items && cart.items[0] && cart.items[0].quantity === 0)
updateCart(cart);
```
If you like this rule, it can be used just fine with Prettier as long as you dont use the `"multi-line"` or `"multi-or-nest"` option.
Example ESLint configuration:
<!-- prettier-ignore -->
```json
{
"rules": {
"curly": ["error", "all"]
}
}
```
### [lines-around-comment]
**This rule can be used with certain options.**
This rule requires empty lines before and/or after comments. Prettier preserves blank lines, with two exceptions:
- Several blank lines in a row are collapsed into a single blank line. This is fine.
- Blank lines at the beginning and end of blocks, objects and arrays are always removed. This may lead to conflicts.
By default, ESLint requires a blank line above the comment is this case:
<!-- prettier-ignore -->
```js
if (result) {
/* comment */
return result;
}
```
However, Prettier removes the blank line:
<!-- prettier-ignore -->
```js
if (result) {
/* comment */
return result;
}
```
If you like this rule, it can be used just fine with Prettier as long as you add some extra configuration to allow comments at the start and end of blocks, objects and arrays.
Example ESLint configuration:
<!-- prettier-ignore -->
```json
{
"rules": {
"lines-around-comment": [
"error",
{
"beforeBlockComment": true,
"afterBlockComment": true,
"beforeLineComment": true,
"afterLineComment": true,
"allowBlockStart": true,
"allowBlockEnd": true,
"allowObjectStart": true,
"allowObjectEnd": true,
"allowArrayStart": true,
"allowArrayEnd": true
}
]
}
}
```
### [max-len]
(The following applies to [vue/max-len] as well.)
**This rule requires special attention when writing code.**
Usually, Prettier takes care of following a maximum line length automatically. However, there are cases where Prettier cant do anything, such as for long strings, regular expressions and comments. Those need to be split up by a human.
If youd like to enforce an even stricter maximum line length policy than Prettier can provide automatically, you can enable this rule. Just remember to keep `max-len`s options and Prettiers `printWidth` option in sync.
Keep in mind that you might have to refactor code slightly if Prettier formats lines in a way that the `max-len` rule does not approve of.
Example ESLint configuration:
<!-- prettier-ignore -->
```json
{
"rules": {
"max-len": ["error", {"code": 80, "ignoreUrls": true}]
}
}
```
### [no-confusing-arrow]
**This rule requires certain options.**
For example, the rule could warn about this line:
<!-- prettier-ignore -->
```js
var x = a => 1 ? 2 : 3;
```
With `{allowParens: true}` (the default since ESLint 6.0.0), adding parentheses is considered a valid way to avoid the arrow confusion:
<!-- prettier-ignore -->
```js
var x = a => (1 ? 2 : 3);
```
While Prettier keeps those parentheses, it removes them if the line is long enough to introduce a line break:
<!-- prettier-ignore -->
```js
EnterpriseCalculator.prototype.calculateImportantNumbers = inputNumber =>
1 ? 2 : 3;
```
With `{allowParens: false}`, ESLint instead suggests switching to an explicit return:
<!-- prettier-ignore -->
```js
var x = a => { return 1 ? 2 : 3; };
```
That causes no problems with Prettier.
If you like this rule, it can be used just fine with Prettier as long as the `allowParens` option is off.
Example ESLint configuration:
<!-- prettier-ignore -->
```json
{
"rules": {
"no-confusing-arrow": ["error", { "allowParens": false }]
}
}
```
(Note: The CLI helper tool considers `{allowParens: true}` to be the default, which is the case since ESLint 6.0.0. The tool will produce a warning if you use the default even if you use an older version of ESLint. It doesnt hurt to explicitly set `{allowParens: false}` even though it is technically redundant. This way you are prepared for a future ESLint upgrade and the CLI tool can be kept simple.)
### [no-mixed-operators]
**This rule requires special attention when writing code.**
This rule forbids mixing certain operators, such as `&&` and `||`.
For example, the rule could warn about this line:
<!-- prettier-ignore -->
```js
var foo = a + b * c;
```
The rule suggests adding parentheses, like this:
<!-- prettier-ignore -->
```js
var foo = a + (b * c);
```
However, Prettier removes many “unnecessary” parentheses, turning it back to:
<!-- prettier-ignore -->
```js
var foo = a + b * c;
```
If you want to use this rule with Prettier, you need to split the expression into another variable:
<!-- prettier-ignore -->
```js
var bar = b * c;
var foo = a + bar;
```
Keep in mind that Prettier prints _some_ “unnecessary” parentheses, though:
<!-- prettier-ignore -->
```js
var foo = (a && b) || c;
```
Example ESLint configuration:
<!-- prettier-ignore -->
```json
{
"rules": {
"no-mixed-operators": "error"
}
}
```
### [no-tabs]
**This rule requires certain Prettier options.**
This rule disallows the use of tab characters at all. It can be used just fine with Prettier as long as you dont configure Prettier to indent using tabs.
Example ESLint configuration:
<!-- prettier-ignore -->
```json
{
"rules": {
"no-tabs": "error"
}
}
```
Example Prettier configuration (this is the default, so adding this is not required):
<!-- prettier-ignore -->
```json
{
"useTabs": false
}
```
**Note:** Since [ESlint 5.7.0] this rule can be configured to work regardless of your Prettier configuration:
<!-- prettier-ignore -->
```json
{
"rules": {
"no-tabs": ["error", {"allowIndentationTabs": true}]
}
}
```
A future version of eslint-config-prettier might check for that automatically.
### [no-unexpected-multiline]
**This rule requires special attention when writing code.**
This rule disallows confusing multiline expressions where a newline looks like it is ending a statement, but is not.
For example, the rule could warn about this:
<!-- prettier-ignore -->
```js
var hello = "world"
[1, 2, 3].forEach(addNumber)
```
Prettier usually formats this in a way that makes it obvious that a semicolon was missing:
<!-- prettier-ignore -->
```js
var hello = "world"[(1, 2, 3)].forEach(addNumber);
```
However, there are cases where Prettier breaks things into several lines such that the `no-unexpected-multiline` conflicts.
<!-- prettier-ignore -->
```js
const value = text.trim().split("\n")[position].toLowerCase();
```
Prettier breaks it up into several lines, though, causing a conflict:
<!-- prettier-ignore -->
```js
const value = text
.trim()
.split("\n")
[position].toLowerCase();
```
If you like this rule, it can usually be used with Prettier without problems, but occasionally you might need to either temporarily disable the rule or refactor your code.
<!-- prettier-ignore -->
```js
const value = text
.trim()
.split("\n")
// eslint-disable-next-line no-unexpected-multiline
[position].toLowerCase();
// Or:
const lines = text.trim().split("\n");
const value = lines[position].toLowerCase();
```
**Note:** If you _do_ enable this rule, you have to run ESLint and Prettier as two separate steps (and ESLint first) in order to get any value out of it. Otherwise Prettier might reformat your code in such a way that ESLint never gets a chance to report anything (as seen in the first example).
Example configuration:
<!-- prettier-ignore -->
```json
{
"rules": {
"no-unexpected-multiline": "error"
}
}
```
### [quotes]
(The following applies to [babel/quotes] and [@typescript-eslint/quotes] as well.)
**This rule requires certain options and certain Prettier options.**
Usually, you dont need this rule at all. But there are two cases where it could be useful:
- To enforce the use of backticks rather than single or double quotes for strings.
- To forbid backticks where regular strings could have been used.
#### Enforce backticks
If youd like all strings to use backticks (never quotes), enable the `"backtick"` option.
Example ESLint configuration:
<!-- prettier-ignore -->
```json
{
"rules": {
"quotes": ["error", "backtick"]
}
}
```
#### Forbid unnecessary backticks
In the following example, the first array item could have been written with quotes instead of backticks.
<!-- prettier-ignore -->
```js
const strings = [
`could have been a regular string`,
`
multiple
lines
`,
`uses ${interpolation}`,
String.raw`\tagged/`,
];
```
If youd like ESLint to enforce `` `could have been a regular string` `` being written as either `"could have been a regular string"` or `'could have been a regular string'`, you need to use some specific configuration. The `quotes` rule has two options, a string option and an object option.
- The first (string) option needs to be set to `"single"` or `"double"` and be kept in sync with Prettiers [singleQuote] option.
- The second (object) option needs the following properties:
- `"avoidEscape": true` to follow Prettiers [string formatting rules].
- `"allowTemplateLiterals": false` to disallow unnecessary backticks.
##### Example double quote configuration
ESLint:
<!-- prettier-ignore -->
```json
{
"rules": {
"quotes": [
"error",
"double",
{ "avoidEscape": true, "allowTemplateLiterals": false }
]
}
}
```
Prettier (this is the default, so adding this is not required):
<!-- prettier-ignore -->
```json
{
"singleQuote": false
}
```
##### Example single quote configuration
ESLint:
<!-- prettier-ignore -->
```json
{
"rules": {
"quotes": [
"error",
"single",
{ "avoidEscape": true, "allowTemplateLiterals": false }
]
}
}
```
Prettier:
<!-- prettier-ignore -->
```json
{
"singleQuote": true
}
```
### [vue/html-self-closing]
**This rule requires certain options.**
This rule enforces whether elements should be self-closing or not.
Prettier generally preserves the way you wrote your elements:
<!-- prettier-ignore -->
```vue
<div />
<div></div>
<MyComponent />
<MyComponent></MyComponent>
<svg><path d="" /></svg>
<svg><path d=""></path></svg>
```
But for known _void_ HTML elements, Prettier always uses the self-closing style. For example, `<img>` is turned into `<img />`.
If you like this rule, it can be used just fine with Prettier as long as you set `html.void` to `"any"`.
Example ESLint configuration:
<!-- prettier-ignore -->
```json
{
"rules": {
"vue/html-self-closing": [
"error",
{
"html": {
"void": "any"
}
}
]
}
}
```
## Other rules worth mentioning
These rules dont conflict with Prettier, but have some gotchas when used with Prettier.
### [no-sequences]
This rule forbids using JavaScripts confusing comma operator (sequence expressions). This piece of code is not doing what it looks like:
<!-- prettier-ignore -->
```js
matrix[4, 7];
```
Prettier adds parentheses to the above to make it clear that a sequence expression is used:
<!-- prettier-ignore -->
```js
matrix[(4, 7)];
```
However, the `no-sequences` rule allows comma operators if the expression sequence is explicitly wrapped in parentheses. Since Prettier automatically wraps them in parentheses, you might never see any warnings from ESLint about comma operators.
Ending up with an accidental sequence expression can easily happen while refactoring. If you want ESLint to catch such mistakes, it is recommended to forbid sequence expressions entirely using [no-restricted-syntax] \([as mentioned in the `no-sequences` documentation][no-sequences-full]):
<!-- prettier-ignore -->
```json
{
"rules": {
"no-restricted-syntax": ["error", "SequenceExpression"]
}
}
```
If you still need to use the comma operator for some edge case, you can place an `// eslint-disable-next-line no-restricted-syntax` comment on the line above the expression. `no-sequences` can safely be disabled if you use the `no-restricted-syntax` approach.
You can also supply a custom message if you want:
<!-- prettier-ignore -->
```json
{
"rules": {
"no-restricted-syntax": [
"error",
{
"selector": "SequenceExpression",
"message": "The comma operator is confusing and a common mistake. Dont use it!"
}
]
}
}
```
## Contributing
eslint-config-prettier has been tested with:
- ESLint 7.12.1
- eslint-config-prettier 6.11.0 and older were tested with ESLint 6.x
- eslint-config-prettier 5.1.0 and older were tested with ESLint 5.x
- eslint-config-prettier 2.10.0 and older were tested with ESLint 4.x
- eslint-config-prettier 2.1.1 and older were tested with ESLint 3.x
- prettier 2.1.2
- @typescript-eslint/eslint-plugin 4.6.0
- eslint-plugin-babel 5.3.1
- eslint-plugin-flowtype 5.2.0
- eslint-plugin-react 7.21.5
- eslint-plugin-standard 4.0.2
- eslint-plugin-unicorn 23.0.0
- eslint-plugin-vue 7.1.0
Have new rules been added since those versions? Have we missed any rules? Is there a plugin you would like to see exclusions for? Open an issue or a pull request!
If youd like to add support for eslint-plugin-foobar, this is how youd go about it:
First, create `foobar.js`:
<!-- prettier-ignore -->
```js
"use strict";
module.exports = {
rules: {
"foobar/some-rule": "off"
}
};
```
Then, create `test-lint/foobar.js`:
<!-- prettier-ignore -->
```js
/* eslint-disable quotes */
"use strict";
// Prettier does not want spaces before the parentheses, but
// `plugin:foobar/recommended` wants one.
console.log();
```
`test-lint/foobar.js` must fail when used with eslint-plugin-foobar and eslint-plugin-prettier at the same time until `"prettier/foobar"` is added to the "extends" property of an ESLint config. The file should be formatted according to Prettier, and that formatting should disagree with the plugin.
Finally, you need to mention the plugin in several places:
- Add `"foobar.js"` to the "files" field in `package.json`.
- Add eslint-plugin-foobar to the "devDependencies" field in `package.json`.
- Make sure that at least one rule from eslint-plugin-foobar gets used in `.eslintrc.base.js`.
- Add it to the list of supported plugins, to the example config and to Contributing section in `README.md`.
When youre done, run `npm test` to verify that you got it all right. It runs several other npm scripts:
- `"test:lint"` makes sure that the files in `test-lint/` pass ESLint when the exclusions from eslint-config-prettier are used. It also lints the code of eslint-config-prettier itself, and checks that Prettier has been run on all files.
- `"test:lint-verify-fail"` is run by a test in `test/lint-verify-fail.test.js`.
- `"test:lint-rules"` is run by a test in `test/rules.test.js`.
- `"test:jest"` runs unit tests that check a number of things:
- That eslint-plugin-foobar is mentioned in all the places shown above.
- That no unknown rules are turned off. This helps catching typos, for example.
- That the CLI works.
- `"test:cli-sanity"` and `"test:cli-sanity-warning"` are sanity checks for the CLI.
## License
[MIT](LICENSE).
[@typescript-eslint/eslint-plugin]: https://github.com/typescript-eslint/typescript-eslint
[@typescript-eslint/quotes]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md
[eslint 5.7.0]: https://eslint.org/blog/2018/10/eslint-v5.7.0-released
[prettier]: https://github.com/prettier/prettier
[arrow-body-style]: https://eslint.org/docs/rules/arrow-body-style
[babel/quotes]: https://github.com/babel/eslint-plugin-babel#rules
[curly]: https://eslint.org/docs/rules/curly
[eslint-config-airbnb]: https://www.npmjs.com/package/eslint-config-airbnb
[eslint-config-prettier#31]: https://github.com/prettier/eslint-config-prettier/issues/31
[eslint-config-prettier#71]: https://github.com/prettier/eslint-config-prettier/issues/71
[eslint-plugin-babel]: https://github.com/babel/eslint-plugin-babel
[eslint-plugin-flowtype]: https://github.com/gajus/eslint-plugin-flowtype
[eslint-plugin-prettier#65]: https://github.com/prettier/eslint-plugin-prettier/issues/65
[eslint-plugin-prettier]: https://github.com/prettier/eslint-plugin-prettier
[eslint-plugin-react]: https://github.com/yannickcr/eslint-plugin-react
[eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard
[eslint-plugin-unicorn]: https://github.com/sindresorhus/eslint-plugin-unicorn
[eslint-plugin-vue]: https://github.com/vuejs/eslint-plugin-vue
[lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment
[max-len]: https://eslint.org/docs/rules/max-len
[multiple configuration files]: https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
[no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow
[no-mixed-operators]: https://eslint.org/docs/rules/no-mixed-operators
[no-restricted-syntax]: https://eslint.org/docs/rules/no-restricted-syntax
[no-sequences-full]: https://eslint.org/docs/rules/no-sequences#when-not-to-use-it
[no-sequences]: https://eslint.org/docs/rules/no-sequences
[no-tabs]: https://eslint.org/docs/rules/no-tabs
[no-unexpected-multiline]: https://eslint.org/docs/rules/no-unexpected-multiline
[overrides]: https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns
[prefer-arrow-callback]: https://eslint.org/docs/rules/prefer-arrow-callback
[quotes]: https://eslint.org/docs/rules/quotes
[singlequote]: https://prettier.io/docs/en/options.html#quotes
[string formatting rules]: https://prettier.io/docs/en/rationale.html#strings
[vue/html-self-closing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md
[vue/max-len]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/max-len.md

10
node_modules/eslint-config-prettier/babel.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
"use strict";
module.exports = {
rules: {
"babel/quotes": 0,
"babel/object-curly-spacing": "off",
"babel/semi": "off",
},
};

207
node_modules/eslint-config-prettier/bin/cli.js generated vendored Normal file
View File

@ -0,0 +1,207 @@
#!/usr/bin/env node
"use strict";
const fs = require("fs");
const path = require("path");
const getStdin = require("get-stdin");
const validators = require("./validators");
const SPECIAL_RULES_URL =
"https://github.com/prettier/eslint-config-prettier#special-rules";
if (module === require.main) {
if (process.argv.length > 2 || process.stdin.isTTY) {
console.error(
[
"This tool checks whether an ESLint configuration contains rules that are",
"unnecessary or conflict with Prettier. Its supposed to be run like this:",
"",
" npx eslint --print-config path/to/main.js | npx eslint-config-prettier-check",
" npx eslint --print-config test/index.js | npx eslint-config-prettier-check",
"",
"Exit codes:",
"",
"0: No automatically detectable problems found.",
"1: Unexpected error.",
"2: Conflicting rules found.",
"",
"For more information, see:",
"https://github.com/prettier/eslint-config-prettier#cli-helper-tool",
].join("\n")
);
process.exit(1);
}
getStdin()
.then((string) => {
const result = processString(string);
if (result.stderr) {
console.error(result.stderr);
}
if (result.stdout) {
console.error(result.stdout);
}
process.exit(result.code);
})
.catch((error) => {
console.error("Unexpected error", error);
process.exit(1);
});
}
function processString(string) {
let config;
try {
config = JSON.parse(string);
} catch (error) {
return {
stderr: `Failed to parse JSON:\n${error.message}`,
code: 1,
};
}
if (
!(
Object.prototype.toString.call(config) === "[object Object]" &&
Object.prototype.toString.call(config.rules) === "[object Object]"
)
) {
return {
stderr: `Expected a \`{"rules: {...}"}\` JSON object, but got:\n${string}`,
code: 1,
};
}
// This used to look at "files" in package.json, but that is not reliable due
// to an npm bug. See:
// https://github.com/prettier/eslint-config-prettier/issues/57
const allRules = Object.assign(
Object.create(null),
...fs
.readdirSync(path.join(__dirname, ".."))
.filter((name) => !name.startsWith(".") && name.endsWith(".js"))
.map((ruleFileName) => require(`../${ruleFileName}`).rules)
);
const regularRules = filterRules(
allRules,
(ruleName, value) => value === "off"
);
const optionsRules = filterRules(
allRules,
(ruleName, value) => value === 0 && ruleName in validators
);
const specialRules = filterRules(
allRules,
(ruleName, value) => value === 0 && !(ruleName in validators)
);
const flaggedRules = Object.keys(config.rules)
.map((ruleName) => {
const value = config.rules[ruleName];
const arrayValue = Array.isArray(value) ? value : [value];
const level = arrayValue[0];
const options = arrayValue.slice(1);
const isOff = level === "off" || level === 0;
return !isOff && ruleName in allRules ? { ruleName, options } : null;
})
.filter(Boolean);
const regularFlaggedRuleNames = filterRuleNames(
flaggedRules,
(ruleName) => ruleName in regularRules
);
const optionsFlaggedRuleNames = filterRuleNames(
flaggedRules,
(ruleName, options) =>
ruleName in optionsRules && !validators[ruleName](options)
);
const specialFlaggedRuleNames = filterRuleNames(
flaggedRules,
(ruleName) => ruleName in specialRules
);
if (
regularFlaggedRuleNames.length === 0 &&
optionsFlaggedRuleNames.length === 0
) {
const baseMessage =
"No rules that are unnecessary or conflict with Prettier were found.";
const message =
specialFlaggedRuleNames.length === 0
? baseMessage
: [
baseMessage,
"",
"However, the following rules are enabled but cannot be automatically checked. See:",
SPECIAL_RULES_URL,
"",
printRuleNames(specialFlaggedRuleNames),
].join("\n");
return {
stdout: message,
code: 0,
};
}
const regularMessage = [
"The following rules are unnecessary or might conflict with Prettier:",
"",
printRuleNames(regularFlaggedRuleNames),
].join("\n");
const optionsMessage = [
"The following rules are enabled with options that might conflict with Prettier. See:",
SPECIAL_RULES_URL,
"",
printRuleNames(optionsFlaggedRuleNames),
].join("\n");
const specialMessage = [
"The following rules are enabled but cannot be automatically checked. See:",
SPECIAL_RULES_URL,
"",
printRuleNames(specialFlaggedRuleNames),
].join("\n");
const message = [
regularFlaggedRuleNames.length === 0 ? null : regularMessage,
optionsFlaggedRuleNames.length === 0 ? null : optionsMessage,
specialFlaggedRuleNames.length === 0 ? null : specialMessage,
]
.filter(Boolean)
.join("\n\n");
return {
stdout: message,
code: 2,
};
}
function filterRules(rules, fn) {
return Object.keys(rules)
.filter((ruleName) => fn(ruleName, rules[ruleName]))
.reduce((obj, ruleName) => {
obj[ruleName] = true;
return obj;
}, Object.create(null));
}
function filterRuleNames(rules, fn) {
return rules
.filter((rule) => fn(rule.ruleName, rule.options))
.map((rule) => rule.ruleName);
}
function printRuleNames(ruleNames) {
return ruleNames
.slice()
.sort()
.map((ruleName) => `- ${ruleName}`)
.join("\n");
}
exports.processString = processString;

54
node_modules/eslint-config-prettier/bin/validators.js generated vendored Normal file
View File

@ -0,0 +1,54 @@
"use strict";
// These validator functions answer the question “Is the config valid?” return
// `false` if the options DO conflict with Prettier, and `true` if they dont.
module.exports = {
curly(options) {
if (options.length === 0) {
return true;
}
const firstOption = options[0];
return firstOption !== "multi-line" && firstOption !== "multi-or-nest";
},
"lines-around-comment"(options) {
if (options.length === 0) {
return false;
}
const firstOption = options[0];
return Boolean(
firstOption &&
firstOption.allowBlockStart &&
firstOption.allowBlockEnd &&
firstOption.allowObjectStart &&
firstOption.allowObjectEnd &&
firstOption.allowArrayStart &&
firstOption.allowArrayEnd
);
},
"no-confusing-arrow"(options) {
if (options.length === 0) {
return false;
}
const firstOption = options[0];
return firstOption ? firstOption.allowParens === false : false;
},
"vue/html-self-closing"(options) {
if (options.length === 0) {
return false;
}
const firstOption = options[0];
return Boolean(
firstOption && firstOption.html && firstOption.html.void === "any"
// Enable when Prettier supports SVG: https://github.com/prettier/prettier/issues/5322
// && firstOption.svg === "any"
);
},
};

15
node_modules/eslint-config-prettier/flowtype.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
"use strict";
module.exports = {
rules: {
"flowtype/boolean-style": "off",
"flowtype/delimiter-dangle": "off",
"flowtype/generic-spacing": "off",
"flowtype/object-type-delimiter": "off",
"flowtype/semi": "off",
"flowtype/space-after-type-colon": "off",
"flowtype/space-before-generic-bracket": "off",
"flowtype/space-before-type-colon": "off",
"flowtype/union-intersection-spacing": "off",
},
};

103
node_modules/eslint-config-prettier/index.js generated vendored Normal file
View File

@ -0,0 +1,103 @@
"use strict";
const includeDeprecated = !process.env.ESLINT_CONFIG_PRETTIER_NO_DEPRECATED;
module.exports = {
rules: Object.assign(
{
// The following rules can be used in some cases. See the README for more
// information. (These are marked with `0` instead of `"off"` so that a
// script can distinguish them.)
"arrow-body-style": 0,
curly: 0,
"lines-around-comment": 0,
"max-len": 0,
"no-confusing-arrow": 0,
"no-mixed-operators": 0,
"no-tabs": 0,
"no-unexpected-multiline": 0,
"prefer-arrow-callback": 0,
quotes: 0,
// The rest are rules that you never need to enable when using Prettier.
"array-bracket-newline": "off",
"array-bracket-spacing": "off",
"array-element-newline": "off",
"arrow-parens": "off",
"arrow-spacing": "off",
"block-spacing": "off",
"brace-style": "off",
"comma-dangle": "off",
"comma-spacing": "off",
"comma-style": "off",
"computed-property-spacing": "off",
"dot-location": "off",
"eol-last": "off",
"func-call-spacing": "off",
"function-call-argument-newline": "off",
"function-paren-newline": "off",
"generator-star": "off",
"generator-star-spacing": "off",
"implicit-arrow-linebreak": "off",
indent: "off",
"jsx-quotes": "off",
"key-spacing": "off",
"keyword-spacing": "off",
"linebreak-style": "off",
"multiline-ternary": "off",
"newline-per-chained-call": "off",
"new-parens": "off",
"no-arrow-condition": "off",
"no-comma-dangle": "off",
"no-extra-parens": "off",
"no-extra-semi": "off",
"no-floating-decimal": "off",
"no-mixed-spaces-and-tabs": "off",
"no-multi-spaces": "off",
"no-multiple-empty-lines": "off",
"no-reserved-keys": "off",
"no-space-before-semi": "off",
"no-trailing-spaces": "off",
"no-whitespace-before-property": "off",
"no-wrap-func": "off",
"nonblock-statement-body-position": "off",
"object-curly-newline": "off",
"object-curly-spacing": "off",
"object-property-newline": "off",
"one-var-declaration-per-line": "off",
"operator-linebreak": "off",
"padded-blocks": "off",
"quote-props": "off",
"rest-spread-spacing": "off",
semi: "off",
"semi-spacing": "off",
"semi-style": "off",
"space-after-function-name": "off",
"space-after-keywords": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-before-function-parentheses": "off",
"space-before-keywords": "off",
"space-in-brackets": "off",
"space-in-parens": "off",
"space-infix-ops": "off",
"space-return-throw-case": "off",
"space-unary-ops": "off",
"space-unary-word-ops": "off",
"switch-colon-spacing": "off",
"template-curly-spacing": "off",
"template-tag-spacing": "off",
"unicode-bom": "off",
"wrap-iife": "off",
"wrap-regex": "off",
"yield-star-spacing": "off",
},
includeDeprecated && {
// Deprecated since version 4.0.0.
// https://github.com/eslint/eslint/pull/8286
"indent-legacy": "off",
// Deprecated since version 3.3.0.
// https://eslint.org/docs/rules/no-spaced-func
"no-spaced-func": "off",
}
),
};

67
node_modules/eslint-config-prettier/package.json generated vendored Normal file
View File

@ -0,0 +1,67 @@
{
"name": "eslint-config-prettier",
"version": "6.15.0",
"license": "MIT",
"author": "Simon Lydell",
"description": "Turns off all rules that are unnecessary or might conflict with Prettier.",
"repository": "prettier/eslint-config-prettier",
"files": [
"bin/",
"@typescript-eslint.js",
"babel.js",
"flowtype.js",
"index.js",
"react.js",
"standard.js",
"unicorn.js",
"vue.js"
],
"bin": {
"eslint-config-prettier-check": "bin/cli.js"
},
"keywords": [
"eslint",
"eslintconfig",
"prettier"
],
"scripts": {
"doctoc": "doctoc README.md && replace \"\\[\\[([\\w/-]+)\\](?:([^\\[\\]]+)\\[([\\w/-]+)\\])?\\]\" \"[\\$1\\$2\\$3]\" README.md",
"prettier": "prettier --write .",
"test:lint": "eslint . && prettier --check .",
"test:lint-verify-fail": "eslint \"test-lint/*.{js,ts,vue}\" --config .eslintrc.base.js --format json",
"test:lint-rules": "eslint index.js --config test-config/.eslintrc.js --format json",
"test:deprecated": "eslint-find-rules --deprecated index.js",
"test:jest": "jest",
"test:cli-sanity": "eslint --print-config index.js | node ./bin/cli.js",
"test:cli-sanity-warning": "eslint --print-config ./bin/cli.js | node ./bin/cli.js",
"test": "npm run test:lint && npm run test:jest && npm run test:cli-sanity && npm run test:cli-sanity-warning"
},
"dependencies": {
"get-stdin": "^6.0.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "4.6.0",
"@typescript-eslint/parser": "4.6.0",
"babel-eslint": "10.1.0",
"cross-spawn": "7.0.3",
"doctoc": "1.4.0",
"eslint": "7.12.1",
"eslint-config-google": "0.14.0",
"eslint-find-rules": "3.6.1",
"eslint-plugin-babel": "5.3.1",
"eslint-plugin-flowtype": "5.2.0",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-react": "7.21.5",
"eslint-plugin-standard": "4.0.2",
"eslint-plugin-unicorn": "23.0.0",
"eslint-plugin-vue": "7.1.0",
"jest": "26.6.1",
"prettier": "2.1.2",
"replace": "1.2.0",
"rimraf": "3.0.2",
"typescript": "4.0.5"
},
"peerDependencies": {
"eslint": ">=3.14.1"
}
}

29
node_modules/eslint-config-prettier/react.js generated vendored Normal file
View File

@ -0,0 +1,29 @@
"use strict";
const includeDeprecated = !process.env.ESLINT_CONFIG_PRETTIER_NO_DEPRECATED;
module.exports = {
rules: Object.assign(
{
"react/jsx-child-element-spacing": "off",
"react/jsx-closing-bracket-location": "off",
"react/jsx-closing-tag-location": "off",
"react/jsx-curly-newline": "off",
"react/jsx-curly-spacing": "off",
"react/jsx-equals-spacing": "off",
"react/jsx-first-prop-new-line": "off",
"react/jsx-indent": "off",
"react/jsx-indent-props": "off",
"react/jsx-max-props-per-line": "off",
"react/jsx-one-expression-per-line": "off",
"react/jsx-props-no-multi-spaces": "off",
"react/jsx-tag-spacing": "off",
"react/jsx-wrap-multilines": "off",
},
includeDeprecated && {
// Deprecated since version 7.0.0.
// https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md#700---2017-05-06
"react/jsx-space-before-closing": "off",
}
),
};

9
node_modules/eslint-config-prettier/standard.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
module.exports = {
rules: {
"standard/array-bracket-even-spacing": "off",
"standard/computed-property-even-spacing": "off",
"standard/object-curly-even-spacing": "off",
},
};

8
node_modules/eslint-config-prettier/unicorn.js generated vendored Normal file
View File

@ -0,0 +1,8 @@
"use strict";
module.exports = {
rules: {
"unicorn/no-nested-ternary": "off",
"unicorn/number-literal-case": "off",
},
};

43
node_modules/eslint-config-prettier/vue.js generated vendored Normal file
View File

@ -0,0 +1,43 @@
"use strict";
module.exports = {
rules: {
"vue/html-self-closing": 0,
"vue/max-len": 0,
"vue/array-bracket-newline": "off",
"vue/array-bracket-spacing": "off",
"vue/arrow-spacing": "off",
"vue/block-spacing": "off",
"vue/block-tag-newline": "off",
"vue/brace-style": "off",
"vue/comma-dangle": "off",
"vue/comma-spacing": "off",
"vue/comma-style": "off",
"vue/dot-location": "off",
"vue/func-call-spacing": "off",
"vue/html-closing-bracket-newline": "off",
"vue/html-closing-bracket-spacing": "off",
"vue/html-end-tags": "off",
"vue/html-indent": "off",
"vue/html-quotes": "off",
"vue/key-spacing": "off",
"vue/keyword-spacing": "off",
"vue/max-attributes-per-line": "off",
"vue/multiline-html-element-content-newline": "off",
"vue/mustache-interpolation-spacing": "off",
"vue/no-extra-parens": "off",
"vue/no-multi-spaces": "off",
"vue/no-spaces-around-equal-signs-in-attribute": "off",
"vue/object-curly-newline": "off",
"vue/object-curly-spacing": "off",
"vue/object-property-newline": "off",
"vue/operator-linebreak": "off",
"vue/script-indent": "off",
"vue/singleline-html-element-content-newline": "off",
"vue/space-in-parens": "off",
"vue/space-infix-ops": "off",
"vue/space-unary-ops": "off",
"vue/template-curly-spacing": "off",
},
};