Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

updating prettier config to enable the prettier/prettier rule #170

Merged
merged 1 commit into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
coverage
tests/fixtures
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Changelog

<!-- ## Unreleased -->
## Unreleased

### Fixed

* Updated `plugin:shopify/prettier` to enable prettier linting. ([#170](https://github.com/Shopify/eslint-plugin-shopify/pull/170))

## [24.2.0] - 2018-09-21

### Added

* Added `plugin:shopify/graphql` to module index. ([#000](https://github.com/Shopify/eslint-plugin-shopify/pull/000))
* Added `plugin:shopify/graphql` to module index. ([#168](https://github.com/Shopify/eslint-plugin-shopify/pull/168))
patsissons marked this conversation as resolved.
Show resolved Hide resolved

### Fixed

Expand Down
1 change: 1 addition & 0 deletions lib/config/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module.exports = {
require('./rules/jsx-a11y'),
require('./rules/lodash'),
require('./rules/node'),
require('./rules/prettier'),
require('./rules/promise'),
require('./rules/react'),
require('./rules/shopify'),
Expand Down
6 changes: 4 additions & 2 deletions lib/config/prettier.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const merge = require('merge');

module.exports = {
extends: ['prettier'],

plugins: ['prettier'],

rules: {
rules: merge(require('./rules/prettier'), {
BPScott marked this conversation as resolved.
Show resolved Hide resolved
// rules to disable to prefer prettier
'shopify/class-property-semi': 'off',
'shopify/binary-assignment-parens': 'off',
Expand All @@ -21,5 +23,5 @@ module.exports = {
// Special rule for 'no-unexpected-multiline'
// https://github.com/prettier/eslint-config-prettier/blob/5399175c37466747aae9d407021dffec2c169c8b/README.md#no-unexpected-multiline
'no-unexpected-multiline': 'error',
},
}),
};
3 changes: 3 additions & 0 deletions lib/config/rules/prettier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'prettier/prettier': 'error',
};
7 changes: 0 additions & 7 deletions lib/config/typescript-prettier.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,5 @@ module.exports = {
rules: {
// rules to disable to prefer prettier
'typescript/member-delimiter-style': 'off',
Copy link
Member

@BPScott BPScott Sep 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like prettier changed to use ; as member delimiters, to match the eslint rule way back in v 1.4.1 as per prettier/prettier#1918, so I think we can remove this too. But that can be done in a different PR.

Copy link
Contributor Author

@patsissons patsissons Sep 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. let's shuffle that in a different PR to keep this one focused.


'prettier/prettier': [
'error',
{
parser: 'typescript',
},
],
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-preset-shopify": "^16.5.0",
"chai": "^4.0.0",
"eslint": "^5.4.0",
"eslint-index": "^1.4.0",
"eslint-plugin-shopify": "file:./.",
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/prettier/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
foo: "bar",
};
5 changes: 5 additions & 0 deletions tests/fixtures/prettier/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eslintConfig": {
"extends": "plugin:shopify/prettier"
}
}
1 change: 1 addition & 0 deletions tests/fixtures/typescript-prettier/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo: string = "bar";
5 changes: 5 additions & 0 deletions tests/fixtures/typescript-prettier/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eslintConfig": {
"extends": "plugin:shopify/typescript-prettier"
}
}
24 changes: 24 additions & 0 deletions tests/lib/config/prettier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* eslint-env node, mocha */
/* eslint-disable flowtype/require-valid-file-annotation */
import {expect} from 'chai';
import {execSync} from 'child_process';

// eslint-disable-next-line shopify/strict-component-boundaries
import {fixtureFile} from '../../utilities';

describe('config', () => {
describe('prettier', () => {
it('validates source files using prettier', () => {
expect(
() =>
execSync(
`node_modules/.bin/eslint --no-ignore ${fixtureFile('prettier')}`,
),
// eslint-disable-next-line function-paren-newline
)
.throws()
.with.property('stdout')
.to.match(/Replace .*"bar".* with .*'bar'/);
}).timeout(8000);
});
});
26 changes: 26 additions & 0 deletions tests/lib/config/typescript-prettier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-env node, mocha */
/* eslint-disable flowtype/require-valid-file-annotation */
import {expect} from 'chai';
import {execSync} from 'child_process';

// eslint-disable-next-line shopify/strict-component-boundaries
import {fixtureFile} from '../../utilities';

describe('config', () => {
describe('typescript-prettier', () => {
it('validates TypeScript source files using prettier', () => {
expect(
() =>
execSync(
`node_modules/.bin/eslint --ext .ts --no-ignore ${fixtureFile(
'typescript-prettier',
)}`,
),
// eslint-disable-next-line function-paren-newline
)
.throws()
.with.property('stdout')
.to.match(/Replace .*"bar".* with .*'bar'/);
}).timeout(8000);
});
});
40 changes: 38 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ assert-plus@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234"

assertion-error@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"

ast-types-flow@0.0.7, ast-types-flow@^0.0.7:
version "0.0.7"
resolved "https://registry.yarnpkg.com/ast-types-flow/-/ast-types-flow-0.0.7.tgz#f70b735c6bca1a5c9c22d982c3e39e7feba3bdad"
Expand Down Expand Up @@ -1086,6 +1090,17 @@ center-align@^0.1.1:
align-text "^0.1.3"
lazy-cache "^1.0.3"

chai@^4.0.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.2.tgz#0f64584ba642f0f2ace2806279f4f06ca23ad73c"
dependencies:
assertion-error "^1.0.1"
check-error "^1.0.1"
deep-eql "^3.0.0"
get-func-name "^2.0.0"
pathval "^1.0.0"
type-detect "^4.0.0"

chalk@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
Expand Down Expand Up @@ -1116,6 +1131,10 @@ chardet@^0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"

check-error@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"

chokidar@^1.6.1:
version "1.7.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
Expand Down Expand Up @@ -1306,6 +1325,12 @@ decamelize@^1.0.0, decamelize@^1.1.1:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"

deep-eql@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df"
dependencies:
type-detect "^4.0.0"

deep-extend@~0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f"
Expand Down Expand Up @@ -1622,7 +1647,7 @@ eslint-plugin-react@7.11.1:
prop-types "^15.6.2"

"eslint-plugin-shopify@file:./.":
version "24.0.0"
version "24.2.0"
dependencies:
babel-eslint "9.0.0"
eslint-config-prettier "3.0.1"
Expand All @@ -1643,7 +1668,6 @@ eslint-plugin-react@7.11.1:
eslint-plugin-react "7.11.1"
eslint-plugin-sort-class-members "1.3.1"
eslint-plugin-typescript "0.12.0"
graphql "^0.13.0"
merge "1.2.0"
pascal-case "^2.0.1"
pkg-dir "2.0.0"
Expand Down Expand Up @@ -2056,6 +2080,10 @@ get-caller-file@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5"

get-func-name@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41"

get-stdin@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b"
Expand Down Expand Up @@ -3088,6 +3116,10 @@ path-type@^2.0.0:
dependencies:
pify "^2.0.0"

pathval@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0"

performance-now@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5"
Expand Down Expand Up @@ -3774,6 +3806,10 @@ type-check@~0.3.2:
dependencies:
prelude-ls "~1.1.2"

type-detect@^4.0.0:
version "4.0.8"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"

typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
Expand Down