Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: prettier/eslint-plugin-prettier
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0813a83512ab52194b4e8da7193daf880a8cbef5
Choose a base ref
...
head repository: prettier/eslint-plugin-prettier
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e53f23b890c9c6e73ba6e58db0d05eb91d962b71
Choose a head ref
  • 5 commits
  • 7 files changed
  • 4 contributors

Commits on Apr 22, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    76bd45e View commit details

Commits on Aug 20, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    crazy-max CrazyMax
    Copy the full SHA
    ec6fbb1 View commit details
  2. build(deps): Bump path-parse from 1.0.6 to 1.0.7 (#425)

    Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
    - [Release notes](https://github.com/jbgutierrez/path-parse/releases)
    - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)
    
    ---
    updated-dependencies:
    - dependency-name: path-parse
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Aug 20, 2021
    Copy the full SHA
    24f957e View commit details
  3. build(deps): Bump glob-parent from 5.0.0 to 5.1.2 (#420)

    Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 5.0.0 to 5.1.2.
    - [Release notes](https://github.com/gulpjs/glob-parent/releases)
    - [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md)
    - [Commits](gulpjs/glob-parent@v5.0.0...v5.1.2)
    
    ---
    updated-dependencies:
    - dependency-name: glob-parent
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Aug 20, 2021
    Copy the full SHA
    b6d075c View commit details
  4. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e53f23b View commit details
Showing with 71 additions and 12 deletions.
  1. +10 −1 .github/workflows/ci.yml
  2. +7 −0 CHANGELOG.md
  3. +15 −5 eslint-plugin-prettier.js
  4. +1 −1 package.json
  5. +27 −1 test/prettier.js
  6. +4 −0 test/prettierrc/no-semi/.prettierrc
  7. +7 −4 yarn.lock
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -12,7 +12,8 @@ jobs:
strategy:
matrix:
eslint-version: [7.x, 6.x, 5.x]
node-version: [14.x, 12.x, 10.x, 8.x, 6.x]
node-version: [16.x, 14.x, 12.x, 10.x, 8.x, 6.x]
test-graphql: [true, false]

exclude:
# eslint 7 does not support node 6 or 8
@@ -26,6 +27,11 @@ jobs:
node-version: 8.x
- eslint-version: 6.x
node-version: 6.x
# the version of graphql-config used in @graphql-eslint/eslint-plugin does not support node 8
- test-graphql: true
node-version: 8.x
- test-graphql: true
node-version: 6.x

steps:
- uses: actions/checkout@v2
@@ -41,5 +47,8 @@ jobs:
- name: Install
run: yarn install

- if: matrix.test-graphql == true
run: yarn add -D @graphql-eslint/eslint-plugin graphql

- name: Test
run: yarn run test
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v3.4.1 (2021-08-20)

* build(deps): Bump glob-parent from 5.0.0 to 5.1.2 ([#420](git@github.com:prettier/eslint-plugin-prettier/issues/420)) ([b6d075c](git@github.com:prettier/eslint-plugin-prettier/commit/b6d075cf7111468e8af4161c306c7f37f09f220e))
* build(deps): Bump path-parse from 1.0.6 to 1.0.7 ([#425](git@github.com:prettier/eslint-plugin-prettier/issues/425)) ([24f957e](git@github.com:prettier/eslint-plugin-prettier/commit/24f957ee2a5476bb9cc8e64921b9841fc751391e))
* feat: support `@graphql-eslint/eslint-plugin` out of box ([#413](git@github.com:prettier/eslint-plugin-prettier/issues/413)) ([ec6fbb1](git@github.com:prettier/eslint-plugin-prettier/commit/ec6fbb159e2454c6e145db55480932dc953cf7c1))
* chore: add tests for Node 16 ([#410](git@github.com:prettier/eslint-plugin-prettier/issues/410)) ([76bd45e](git@github.com:prettier/eslint-plugin-prettier/commit/76bd45ece6d56eb52f75db6b4a1efdd2efb56392))

## v3.4.0 (2021-04-15)

* feat: support processor virtual filename ([#401](git@github.com:prettier/eslint-plugin-prettier/issues/401)) ([ee0ccc6](git@github.com:prettier/eslint-plugin-prettier/commit/ee0ccc6ac06d13cd546e78b444e53164f59eb27f))
20 changes: 15 additions & 5 deletions eslint-plugin-prettier.js
Original file line number Diff line number Diff line change
@@ -165,7 +165,7 @@ module.exports = {
})
: null;

const prettierFileInfo = prettier.getFileInfo.sync(
const { ignored, inferredParser } = prettier.getFileInfo.sync(
onDiskFilepath,
Object.assign(
{},
@@ -175,7 +175,7 @@ module.exports = {
);

// Skip if file is ignored using a .prettierignore file
if (prettierFileInfo.ignored) {
if (ignored) {
return;
}

@@ -206,11 +206,21 @@ module.exports = {
// * Prettier supports parsing the file type
// * There is an ESLint processor that extracts JavaScript snippets
// from the file type.
const parserBlocklist = [null, 'graphql', 'markdown', 'html'];
const parserBlocklist = [null, 'markdown', 'html'];

let inferParserToBabel =
parserBlocklist.indexOf(inferredParser) !== -1;

if (
filepath === onDiskFilepath &&
parserBlocklist.indexOf(prettierFileInfo.inferredParser) !== -1
// it could be processed by `@graphql-eslint/eslint-plugin` or `eslint-plugin-graphql`
inferredParser === 'graphql' &&
// for `eslint-plugin-graphql`, see https://github.com/apollographql/eslint-plugin-graphql/blob/master/src/index.js#L416
source.startsWith('ESLintPluginGraphQLFile`')
) {
inferParserToBabel = true;
}

if (filepath === onDiskFilepath && inferParserToBabel) {
// Prettier v1.16.0 renamed the `babylon` parser to `babel`
// Use the modern name if available
const supportBabelParser = prettier
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-prettier",
"version": "3.4.0",
"version": "3.4.1",
"description": "Runs prettier as an eslint rule",
"keywords": [
"eslint",
28 changes: 27 additions & 1 deletion test/prettier.js
Original file line number Diff line number Diff line change
@@ -26,6 +26,14 @@ const RuleTester = require('eslint').RuleTester;

const ruleTester = new RuleTester();

let graphqlEslintParserPath;

try {
graphqlEslintParserPath = require.resolve('@graphql-eslint/eslint-plugin');
} catch (e) {
// ignore
}

ruleTester.run('prettier', rule, {
valid: [
// Correct style.
@@ -77,8 +85,26 @@ ruleTester.run('prettier', rule, {
{
code: `('');\n`,
filename: path.join(__filename, '0_fake_virtual_name.js')
},
{
code: 'ESLintPluginGraphQLFile`type Query {\n foo: String!\n}`\n',
filename: getPrettierRcJsFilename('no-semi', 'dummy.graphql'),
parserOptions: {
ecmaVersion: 2015
}
}
],
].concat(
graphqlEslintParserPath
? {
code: `type Query {
foo: String!
}
`,
filename: 'valid.graphql',
parser: graphqlEslintParserPath
}
: []
),
invalid: [
'01',
'02',
4 changes: 4 additions & 0 deletions test/prettierrc/no-semi/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"semi": false
}

11 changes: 7 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -540,8 +540,9 @@ get-stdin@^6.0.0:
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b"

glob-parent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.0.0.tgz#1dc99f0f39b006d3e92c2c284068382f0c20e954"
version "5.1.2"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
dependencies:
is-glob "^4.0.1"

@@ -642,6 +643,7 @@ is-date-object@^1.0.1:
is-extglob@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=

is-fullwidth-code-point@^2.0.0:
version "2.0.0"
@@ -856,8 +858,9 @@ path-key@^3.1.0:
integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==

path-parse@^1.0.5:
version "1.0.6"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
version "1.0.7"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==

prelude-ls@^1.2.1:
version "1.2.1"