Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2024-12-03 18:37:29 +00:00
parent 49f7b34c3d
commit 5261a1223f
1640 changed files with 174830 additions and 182292 deletions

View file

@ -6,6 +6,21 @@ If your desired formatting does not match Prettiers output, you should use a
Please read [Integrating with linters](https://prettier.io/docs/en/integrating-with-linters.html) before installing.
## TOC <!-- omit in toc -->
- [Sample](#sample)
- [Installation](#installation)
- [Configuration (legacy: `.eslintrc*`)](#configuration-legacy-eslintrc)
- [Configuration (new: `eslint.config.js`)](#configuration-new-eslintconfigjs)
- [`Svelte` support](#svelte-support)
- [`arrow-body-style` and `prefer-arrow-callback` issue](#arrow-body-style-and-prefer-arrow-callback-issue)
- [Options](#options)
- [Sponsors](#sponsors)
- [Backers](#backers)
- [Contributing](#contributing)
- [Changelog](#changelog)
- [License](#license)
## Sample
```js
@ -37,63 +52,52 @@ error: Delete `;` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.j
## Installation
```sh
npm install --save-dev eslint-plugin-prettier
npm install --save-dev eslint-plugin-prettier eslint-config-prettier
npm install --save-dev --save-exact prettier
```
**_`eslint-plugin-prettier` does not install Prettier or ESLint for you._** _You must install these yourself._
Then, in your `.eslintrc.json`:
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`](https://github.com/prettier/eslint-config-prettier) to disable all formatting-related ESLint rules.
## Configuration (legacy: `.eslintrc*`)
For [legacy configuration](https://eslint.org/docs/latest/use/configure/configuration-files), this plugin ships with a `plugin:prettier/recommended` config that sets up both `eslint-plugin-prettier` and [`eslint-config-prettier`](https://github.com/prettier/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:
```json
{
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
"extends": ["plugin:prettier/recommended"]
}
```
## Recommended Configuration
This will:
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.) You can use [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) to disable all formatting-related ESLint rules.
- Enable the `prettier/prettier` rule.
- Disable the `arrow-body-style` and `prefer-arrow-callback` rules which are problematic with this plugin - see the below for why.
- Enable the `eslint-config-prettier` config which will turn off ESLint rules that conflict with Prettier.
This plugin ships with a `plugin:prettier/recommended` config that sets up both the plugin and `eslint-config-prettier` in one go.
## Configuration (new: `eslint.config.js`)
1. In addition to the above installation instructions, install `eslint-config-prettier`:
For [flat configuration](https://eslint.org/docs/latest/use/configure/configuration-files-new), this plugin ships with an `eslint-plugin-prettier/recommended` config that sets up both `eslint-plugin-prettier` and [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier) in one go.
```sh
npm install --save-dev eslint-config-prettier
```
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:
2. Then you need to add `plugin:prettier/recommended` as the _last_ extension in your `.eslintrc.json`:
```js
const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
```json
{
"extends": ["plugin:prettier/recommended"]
}
```
You can then set Prettier's own options inside a `.prettierrc` file.
Exactly what does `plugin:prettier/recommended` do? Well, this is what it expands to:
```json
{
"extends": ["prettier"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"arrow-body-style": "off",
"prefer-arrow-callback": "off"
}
}
module.exports = [
// Any other config imports go at the top
eslintPluginPrettierRecommended,
];
```
- `"extends": ["prettier"]` enables the config from `eslint-config-prettier`, which turns off some ESLint rules that conflict with Prettier.
- `"plugins": ["prettier"]` registers this plugin.
- `"prettier/prettier": "error"` turns on the rule provided by this plugin, which runs Prettier from within ESLint.
- `"arrow-body-style": "off"` and `"prefer-arrow-callback": "off"` turns off two ESLint core rules that unfortunately are problematic with this plugin see the next section.
This will:
- Enable the `prettier/prettier` rule.
- Disable the `arrow-body-style` and `prefer-arrow-callback` rules which are problematic with this plugin - see the below for why.
- Enable the `eslint-config-prettier` config which will turn off ESLint rules that conflict with Prettier.
## `Svelte` support
@ -173,6 +177,18 @@ If youre fixing large of amounts of previously unformatted code, consider tem
---
## Sponsors
| @prettier/plugin-eslint | eslint-config-prettier | eslint-plugin-prettier | prettier-eslint | prettier-eslint-cli |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [![@prettier/plugin-eslint Open Collective sponsors](https://opencollective.com/prettier-plugin-eslint/tiers/sponsors.svg)](https://opencollective.com/prettier-plugin-eslint) | [![eslint-config-prettier Open Collective backers](https://opencollective.com/eslint-config-prettier/tiers/sponsors.svg)](https://opencollective.com/eslint-config-prettier) | [![eslint-plugin-prettier Open Collective backers](https://opencollective.com/eslint-plugin-prettier/tiers/sponsors.svg)](https://opencollective.com/rxts) | [![prettier-eslint Open Collective sponsors](https://opencollective.com/prettier-eslint/tiers/sponsors.svg)](https://opencollective.com/prettier-eslint) | [![prettier-eslint-cli Open Collective backers](https://opencollective.com/prettier-eslint-cli/tiers/sponsors.svg)](https://opencollective.com/prettier-eslint-cli) |
## Backers
| @prettier/plugin-eslint | eslint-config-prettier | eslint-plugin-prettier | prettier-eslint | prettier-eslint-cli |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [![@prettier/plugin-eslint Open Collective backers](https://opencollective.com/prettier-plugin-eslint/tiers/backers.svg)](https://opencollective.com/prettier-plugin-eslint) | [![eslint-config-prettier Open Collective backers](https://opencollective.com/eslint-config-prettier/tiers/backers.svg)](https://opencollective.com/eslint-config-prettier) | [![eslint-plugin-prettier Open Collective backers](https://opencollective.com/eslint-plugin-prettier/tiers/backers.svg)](https://opencollective.com/rxts) | [![prettier-eslint Open Collective backers](https://opencollective.com/prettier-eslint/tiers/backers.svg)](https://opencollective.com/prettier-eslint) | [![prettier-eslint-cli Open Collective backers](https://opencollective.com/prettier-eslint-cli/tiers/backers.svg)](https://opencollective.com/prettier-eslint-cli) |
## Contributing
See [CONTRIBUTING.md](https://github.com/prettier/eslint-plugin-prettier/blob/master/CONTRIBUTING.md)

View file

@ -9,8 +9,10 @@
* @typedef {import('eslint').AST.Range} Range
* @typedef {import('eslint').AST.SourceLocation} SourceLocation
* @typedef {import('eslint').ESLint.Plugin} Plugin
* @typedef {import('eslint').ESLint.ObjectMetaProperties} ObjectMetaProperties
* @typedef {import('prettier').FileInfoOptions} FileInfoOptions
* @typedef {import('prettier').Options & { onDiskFilepath: string, parserPath: string, usePrettierrc?: boolean }} Options
* @typedef {import('prettier').Options} PrettierOptions
* @typedef {PrettierOptions & { onDiskFilepath: string, parserMeta?: ObjectMetaProperties['meta'], parserPath?: string, usePrettierrc?: boolean }} Options
*/
'use strict';
@ -23,6 +25,7 @@ const {
showInvisibles,
generateDifferences,
} = require('prettier-linter-helpers');
const { name, version } = require('./package.json');
// ------------------------------------------------------------------------------
// Constants
@ -54,8 +57,11 @@ let prettierFormat;
function reportDifference(context, difference) {
const { operation, offset, deleteText = '', insertText = '' } = difference;
const range = /** @type {Range} */ ([offset, offset + deleteText.length]);
// `context.getSourceCode()` was deprecated in ESLint v8.40.0 and replaced
// with the `sourceCode` property.
// TODO: Only use property when our eslint peerDependency is >=8.40.0.
const [start, end] = range.map(index =>
context.getSourceCode().getLocFromIndex(index),
(context.sourceCode ?? context.getSourceCode()).getLocFromIndex(index),
);
context.report({
@ -77,6 +83,7 @@ function reportDifference(context, difference) {
* @type {Plugin}
*/
const eslintPluginPrettier = {
meta: { name, version },
configs: {
recommended: {
extends: ['prettier'],
@ -130,14 +137,26 @@ const eslintPluginPrettier = {
*/
const fileInfoOptions =
(context.options[1] && context.options[1].fileInfoOptions) || {};
const sourceCode = context.getSourceCode();
const filepath = context.getFilename();
// `context.getSourceCode()` was deprecated in ESLint v8.40.0 and replaced
// with the `sourceCode` property.
// TODO: Only use property when our eslint peerDependency is >=8.40.0.
const sourceCode = context.sourceCode ?? context.getSourceCode();
// `context.getFilename()` was deprecated in ESLint v8.40.0 and replaced
// with the `filename` property.
// TODO: Only use property when our eslint peerDependency is >=8.40.0.
const filepath = context.filename ?? context.getFilename();
// Processors that extract content from a file, such as the markdown
// plugin extracting fenced code blocks may choose to specify virtual
// file paths. If this is the case then we need to resolve prettier
// config and file info using the on-disk path instead of the virtual
// path.
const onDiskFilepath = context.getPhysicalFilename();
// `context.getPhysicalFilename()` was deprecated in ESLint v8.40.0 and replaced
// with the `physicalFilename` property.
// TODO: Only use property when our eslint peerDependency is >=8.40.0.
const onDiskFilepath =
context.physicalFilename ?? context.getPhysicalFilename();
const source = sourceCode.text;
return {
@ -150,10 +169,12 @@ const eslintPluginPrettier = {
}
/**
* @type {{}}
* @type {PrettierOptions}
*/
const eslintPrettierOptions = context.options[0] || {};
const parser = context.languageOptions?.parser;
// prettier.format() may throw a SyntaxError if it cannot parse the
// source code it is given. Usually for JS files this isn't a
// problem as ESLint will report invalid syntax before trying to
@ -173,6 +194,12 @@ const eslintPluginPrettier = {
...eslintPrettierOptions,
filepath,
onDiskFilepath,
parserMeta:
parser &&
(parser.meta ?? {
name: parser.name,
version: parser.version,
}),
parserPath: context.parserPath,
usePrettierrc,
},

View file

@ -1,6 +1,6 @@
{
"name": "eslint-plugin-prettier",
"version": "5.0.0",
"version": "5.2.1",
"description": "Runs prettier as an eslint rule",
"repository": "git+https://github.com/prettier/eslint-plugin-prettier.git",
"homepage": "https://github.com/prettier/eslint-plugin-prettier#readme",
@ -8,17 +8,30 @@
"contributors": [
"JounQin (https://github.com/JounQin) <admin@1stg.me>"
],
"funding": "https://opencollective.com/prettier",
"funding": "https://opencollective.com/eslint-plugin-prettier",
"license": "MIT",
"packageManager": "pnpm@7.33.3",
"packageManager": "pnpm@7.33.5",
"engines": {
"node": "^14.18.0 || >=16.0.0"
},
"main": "eslint-plugin-prettier.js",
"exports": {
".": {
"types": "./eslint-plugin-prettier.d.ts",
"default": "./eslint-plugin-prettier.js"
},
"./recommended": {
"types": "./recommended.d.ts",
"default": "./recommended.js"
},
"./package.json": "./package.json"
},
"types": "eslint-plugin-prettier.d.ts",
"files": [
"eslint-plugin-prettier.d.ts",
"eslint-plugin-prettier.js",
"recommended.d.ts",
"recommended.js",
"worker.js"
],
"keywords": [
@ -30,6 +43,7 @@
"peerDependencies": {
"@types/eslint": ">=8.0.0",
"eslint": ">=8.0.0",
"eslint-config-prettier": "*",
"prettier": ">=3.0.0"
},
"peerDependenciesMeta": {
@ -42,42 +56,47 @@
},
"dependencies": {
"prettier-linter-helpers": "^1.0.0",
"synckit": "^0.8.5"
"synckit": "^0.9.1"
},
"devDependencies": {
"@1stg/remark-preset": "^2.0.0",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@commitlint/config-conventional": "^17.6.6",
"@eslint-community/eslint-plugin-eslint-comments": "^3.2.1",
"@graphql-eslint/eslint-plugin": "^3.20.0",
"@types/eslint": "^8.44.0",
"@types/prettier-linter-helpers": "^1.0.1",
"commitlint": "^17.6.6",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@commitlint/config-conventional": "^18.4.3",
"@eslint-community/eslint-plugin-eslint-comments": "^4.1.0",
"@eslint/js": "^8.56.0",
"@graphql-eslint/eslint-plugin": "^3.20.1",
"@html-eslint/parser": "^0.24.1",
"@prettier/plugin-pug": "^3.0.0",
"@types/eslint": "^8.56.0",
"@types/prettier-linter-helpers": "^1.0.4",
"commitlint": "^18.4.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-formatter-friendly": "^7.0.0",
"eslint-mdx": "^2.1.0",
"eslint-plugin-eslint-plugin": "^5.1.0",
"eslint-plugin-mdx": "^2.1.0",
"eslint-plugin-n": "^16.0.1",
"eslint-mdx": "^2.3.0",
"eslint-plugin-eslint-plugin": "^5.2.1",
"eslint-plugin-mdx": "^2.3.0",
"eslint-plugin-n": "^16.5.0",
"eslint-plugin-prettier": "link:.",
"eslint-plugin-svelte": "^2.32.2",
"eslint-plugin-pug": "^1.2.5",
"eslint-plugin-svelte": "^2.35.1",
"eslint-plugin-svelte3": "^4.0.0",
"graphql": "^16.7.1",
"lint-staged": "^13.2.3",
"graphql": "^16.8.1",
"lint-staged": "^15.2.0",
"mocha": "^10.2.0",
"prettier": "^3.0.0",
"prettier": "^3.1.1",
"prettier-plugin-pkg": "^0.18.0",
"simple-git-hooks": "^2.8.1",
"svelte": "^4.0.5",
"vue-eslint-parser": "^9.3.1"
"prettier-plugin-svelte": "^3.1.2",
"simple-git-hooks": "^2.9.0",
"svelte": "^4.2.8",
"vue-eslint-parser": "^9.3.2"
},
"scripts": {
"check": "prettier --check . && pnpm lint",
"format": "prettier --write . && pnpm lint --fix",
"lint": "eslint . --cache -f friendly --max-warnings 10",
"prerelease": "pnpm format && pnpm test",
"release": "changeset publish",
"release": "pnpm check && pnpm test && changeset publish",
"test": "pnpm lint && mocha"
}
}

5
node_modules/eslint-plugin-prettier/recommended.d.ts generated vendored Normal file
View file

@ -0,0 +1,5 @@
import { Linter } from 'eslint';
declare const recommendedConfig: Linter.FlatConfig;
export = recommendedConfig;

17
node_modules/eslint-plugin-prettier/recommended.js generated vendored Normal file
View file

@ -0,0 +1,17 @@
const eslintConfigPrettier = require('eslint-config-prettier');
const eslintPluginPrettier = require('./eslint-plugin-prettier');
// Merge the contents of eslint-config-prettier into every
module.exports = {
...eslintConfigPrettier,
plugins: {
...eslintConfigPrettier.plugins,
prettier: eslintPluginPrettier,
},
rules: {
...eslintConfigPrettier.rules,
'prettier/prettier': 'error',
'arrow-body-style': 'off',
'prefer-arrow-callback': 'off',
},
};

View file

@ -2,7 +2,8 @@
/**
* @typedef {import('prettier').FileInfoOptions} FileInfoOptions
* @typedef {import('prettier').Options & { onDiskFilepath: string, parserPath: string, usePrettierrc?: boolean }} Options
* @typedef {import('eslint').ESLint.ObjectMetaProperties} ObjectMetaProperties
* @typedef {import('prettier').Options & { onDiskFilepath: string, parserMeta?: ObjectMetaProperties['meta'], parserPath?: string, usePrettierrc?: boolean }} Options
*/
const { runAsWorker } = require('synckit');
@ -24,6 +25,7 @@ runAsWorker(
{
filepath,
onDiskFilepath,
parserMeta,
parserPath,
usePrettierrc,
...eslintPrettierOptions
@ -58,7 +60,7 @@ runAsWorker(
return;
}
const initialOptions = {};
const initialOptions = { parser: inferredParser ?? 'babel' };
// ESLint supports processors that let you extract and lint JS
// fragments within a non-JS language. In the cases where prettier
@ -94,9 +96,7 @@ runAsWorker(
// 2. `eslint-plugin-html`
// 3. `eslint-plugin-markdown@1` (replacement: `eslint-plugin-markdown@2+`)
// 4. `eslint-plugin-svelte3` (replacement: `eslint-plugin-svelte@2+`)
const parserBlocklist = [null, 'markdown', 'html'];
let inferParserToBabel = parserBlocklist.includes(inferredParser);
let inferParserToBabel = false;
switch (inferredParser) {
// it could be processed by `@graphql-eslint/eslint-plugin` or `eslint-plugin-graphql`
@ -109,10 +109,37 @@ runAsWorker(
}
break;
}
case 'html': {
// it could be processed by `eslint-plugin-html` or correctly parsed by `@html-eslint/parser`
if (
(typeof parserMeta !== 'undefined' &&
parserMeta.name !== '@html-eslint/parser') ||
(typeof parserPath === 'string' &&
!/([\\/])@html-eslint\1parser\1/.test(parserPath))
) {
inferParserToBabel = true;
}
break;
}
case 'markdown': {
// it could be processed by `eslint-plugin-markdown@1` or correctly parsed by `eslint-mdx`
if (
(typeof parserMeta !== 'undefined' &&
parserMeta.name !== 'eslint-mdx') ||
(typeof parserPath === 'string' &&
!/([\\/])eslint-mdx\1/.test(parserPath))
) {
inferParserToBabel = true;
}
break;
}
// it could be processed by `@ota-meshi/eslint-plugin-svelte`, `eslint-plugin-svelte` or `eslint-plugin-svelte3`
case 'svelte': {
// The `source` would be modified by `eslint-plugin-svelte3`
if (!parserPath.includes('svelte-eslint-parser')) {
if (
typeof parserPath === 'string' &&
!/([\\/])svelte-eslint-parser\1/.test(parserPath)
) {
// We do not support `eslint-plugin-svelte3`,
// the users should run `prettier` on `.svelte` files manually
return;
@ -142,12 +169,16 @@ runAsWorker(
'mdx',
'angular',
'svelte',
'pug',
];
if (parserBlocklist.includes(/** @type {string} */ (inferredParser))) {
return;
}
}
/**
* @type {import('prettier').Options}
*/
const prettierOptions = {
...initialOptions,
...prettierRcOptions,