Skip to content

Commit

Permalink
Enforce Prettier (check if prettier is run in lint script) (#1442)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen1 authored and devongovett committed May 28, 2018
1 parent c600d44 commit 523ee0f
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 64 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
src/builtins
test/integration
test/input
26 changes: 16 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
"type": "git",
"url": "https://github.com/parcel-bundler/parcel.git"
},
"files": ["bin/", "lib/", "src/", "index.js"],
"files": [
"bin/",
"lib/",
"src/",
"index.js"
],
"dependencies": {
"babel-code-frame": "^6.26.0",
"babel-core": "^6.25.0",
Expand Down Expand Up @@ -78,15 +83,15 @@
"graphql-tag": "^2.6.0",
"husky": "^0.14.3",
"less": "^3.0.1",
"lint-staged": "^7.0.5",
"lint-staged": "^7.1.2",
"mocha": "^5.1.1",
"ncp": "^2.0.0",
"nib": "^1.1.2",
"node-sass": "^4.7.2",
"nyc": "^11.1.0",
"postcss-modules": "^1.1.0",
"posthtml-include": "^1.1.0",
"prettier": "^1.9.1",
"prettier": "^1.13.0",
"pug": "^2.0.3",
"rimraf": "^2.6.1",
"sinon": "^5.0.1",
Expand All @@ -101,15 +106,13 @@
"test-coverage": "rm -rf coverage/* && nyc yarn test",
"report-coverage": "nyc report --reporter=lcov && codecov",
"test-ci": "yarn test-coverage && yarn report-coverage",
"format": "prettier --write './{src,bin,test}/**/*.{js,json,md}'",
"format": "prettier --write \"./{src,bin,test}/**/*.{js,json,md}\"",
"build": "yarn minify && babel src -d lib && ncp src/builtins lib/builtins",
"prepublish": "yarn build",
"minify":
"uglifyjs -c -m -o src/builtins/prelude.min.js src/builtins/prelude.js",
"minify": "uglifyjs -c -m -o src/builtins/prelude.min.js src/builtins/prelude.js",
"precommit": "npm run lint && lint-staged",
"lint": "eslint .",
"postinstall":
"node -e \"console.log('\\u001b[35m\\u001b[1mLove Parcel? You can now donate to our open collective:\\u001b[22m\\u001b[39m\\n > \\u001b[34mhttps://opencollective.com/parcel/donate\\u001b[0m')\""
"lint": "eslint . && prettier \"./{src,bin,test}/**/*.{js,json,md}\" --list-different",
"postinstall": "node -e \"console.log('\\u001b[35m\\u001b[1mLove Parcel? You can now donate to our open collective:\\u001b[22m\\u001b[39m\\n > \\u001b[34mhttps://opencollective.com/parcel/donate\\u001b[0m')\""
},
"bin": {
"parcel": "bin/cli.js"
Expand All @@ -118,7 +121,10 @@
"node": ">= 6.0.0"
},
"lint-staged": {
"*.{js,json,md}": ["prettier --write", "git add"]
"*.{js,json,md}": [
"prettier --write",
"git add"
]
},
"collective": {
"type": "opencollective",
Expand Down
6 changes: 3 additions & 3 deletions src/Bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ class Bundler extends EventEmitter {
});
});
}
this.emit('buildStart', this.entryFiles)

this.emit('buildStart', this.entryFiles);

let isInitialBundle = !this.entryAssets;
let startTime = Date.now();
this.pending = true;
Expand Down
18 changes: 14 additions & 4 deletions src/assets/SASSAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,28 @@ class SASSAsset extends Asset {
path.dirname(this.name)
);
opts.data = opts.data ? opts.data + os.EOL + code : code;
let type = this.options.rendition ? this.options.rendition.type : path.extname(this.name).toLowerCase().replace('.','');
opts.indentedSyntax = typeof opts.indentedSyntax === 'boolean' ? opts.indentedSyntax : type === 'sass';
let type = this.options.rendition
? this.options.rendition.type
: path
.extname(this.name)
.toLowerCase()
.replace('.', '');
opts.indentedSyntax =
typeof opts.indentedSyntax === 'boolean'
? opts.indentedSyntax
: type === 'sass';

opts.functions = Object.assign({}, opts.functions, {
url: node => {
let filename = this.addURLDependency(node.getValue());
return new sass.types.String(`url(${JSON.stringify(filename)})`);
}
});

opts.importer = opts.importer || [];
opts.importer = Array.isArray(opts.importer) ? opts.importer : [opts.importer];
opts.importer = Array.isArray(opts.importer)
? opts.importer
: [opts.importer];
opts.importer.push((url, prev, done) => {
if (!/^(~|\.\/|\/)/.test(url)) {
url = './' + url;
Expand Down
3 changes: 1 addition & 2 deletions src/utils/md5.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ function md5(string) {

md5.file = function(filename) {
return new Promise((resolve, reject) => {
fs
.createReadStream(filename)
fs.createReadStream(filename)
.pipe(crypto.createHash('md5').setEncoding('hex'))
.on('finish', function() {
resolve(this.read());
Expand Down
1 change: 1 addition & 0 deletions test/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('graphql', function() {
firstName
lastName
}
`.definitions
);
});
Expand Down
88 changes: 43 additions & 45 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
esutils "^2.0.2"
js-tokens "^3.0.0"

"@samverschueren/stream-to-observable@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f"
dependencies:
any-observable "^0.3.0"

"@sinonjs/formatio@^2.0.0":
version "2.0.0"
resolved "http://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz#84db7e9eb5531df18a8c5e0bfb6e449e55e654b2"
Expand Down Expand Up @@ -139,9 +145,9 @@ ansi-styles@^3.2.0, ansi-styles@^3.2.1:
dependencies:
color-convert "^1.9.0"

any-observable@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/any-observable/-/any-observable-0.2.0.tgz#c67870058003579009083f54ac0abafb5c33d242"
any-observable@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/any-observable/-/any-observable-0.3.0.tgz#af933475e5806a67d0d7df090dd5e8bef65d119b"

anymatch@^1.3.0:
version "1.3.2"
Expand Down Expand Up @@ -1504,14 +1510,13 @@ [email protected], core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"

cosmiconfig@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-4.0.0.tgz#760391549580bbd2df1e562bc177b13c290972dc"
cosmiconfig@^5.0.2:
version "5.0.5"
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.0.5.tgz#a809e3c2306891ce17ab70359dc8bdf661fe2cd0"
dependencies:
is-directory "^0.3.1"
js-yaml "^3.9.0"
parse-json "^4.0.0"
require-from-string "^2.0.1"

create-ecdh@^4.0.0:
version "4.0.1"
Expand Down Expand Up @@ -3286,11 +3291,11 @@ is-obj@^1.0.0, is-obj@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f"

is-observable@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/is-observable/-/is-observable-0.2.0.tgz#b361311d83c6e5d726cabf5e250b0237106f5ae2"
is-observable@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-observable/-/is-observable-1.1.0.tgz#b3e986c8f44de950867cab5403f5a3465005975e"
dependencies:
symbol-observable "^0.2.2"
symbol-observable "^1.1.0"

is-odd@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -3792,22 +3797,22 @@ levn@^0.3.0, levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"

lint-staged@^7.0.5:
version "7.1.0"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-7.1.0.tgz#1514a5b71b8d9492ca0c3d2a44769cbcbc8bcc79"
lint-staged@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-7.1.2.tgz#140b13519a0f9c1f227f4a8b7e1321852aeea860"
dependencies:
app-root-path "^2.0.1"
chalk "^2.3.1"
commander "^2.14.1"
cosmiconfig "^4.0.0"
cosmiconfig "^5.0.2"
debug "^3.1.0"
dedent "^0.7.0"
execa "^0.9.0"
find-parent-dir "^0.3.0"
is-glob "^4.0.0"
is-windows "^1.0.2"
jest-validate "^22.4.0"
listr "^0.13.0"
listr "^0.14.1"
lodash "^4.17.5"
log-symbols "^2.2.0"
micromatch "^3.1.8"
Expand Down Expand Up @@ -3846,15 +3851,15 @@ listr-verbose-renderer@^0.4.0:
date-fns "^1.27.2"
figures "^1.7.0"

listr@^0.13.0:
version "0.13.0"
resolved "https://registry.yarnpkg.com/listr/-/listr-0.13.0.tgz#20bb0ba30bae660ee84cc0503df4be3d5623887d"
listr@^0.14.1:
version "0.14.1"
resolved "https://registry.yarnpkg.com/listr/-/listr-0.14.1.tgz#8a7afa4a7135cee4c921d128e0b7dfc6e522d43d"
dependencies:
chalk "^1.1.3"
"@samverschueren/stream-to-observable" "^0.3.0"
cli-truncate "^0.2.1"
figures "^1.7.0"
indent-string "^2.1.0"
is-observable "^0.2.0"
is-observable "^1.1.0"
is-promise "^2.1.0"
is-stream "^1.1.0"
listr-silent-renderer "^1.1.1"
Expand All @@ -3864,8 +3869,7 @@ listr@^0.13.0:
log-update "^1.0.2"
ora "^0.2.3"
p-map "^1.1.1"
rxjs "^5.4.2"
stream-to-observable "^0.2.0"
rxjs "^6.1.0"
strip-ansi "^3.0.1"

load-json-file@^1.0.0:
Expand Down Expand Up @@ -5351,10 +5355,14 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"

prettier@^1.11.1, prettier@^1.9.1:
prettier@^1.11.1:
version "1.12.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325"

prettier@^1.13.0:
version "1.13.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.13.0.tgz#054de8d5fb1a4405c845d16183f58a2c301f6f16"

pretty-format@^22.4.3:
version "22.4.3"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-22.4.3.tgz#f873d780839a9c02e9664c8a082e9ee79eaac16f"
Expand Down Expand Up @@ -5796,10 +5804,6 @@ require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"

require-from-string@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909"

require-main-filename@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
Expand Down Expand Up @@ -5890,11 +5894,11 @@ rx-lite@*, rx-lite@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444"

rxjs@^5.4.2:
version "5.5.10"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.10.tgz#fde02d7a614f6c8683d0d1957827f492e09db045"
rxjs@^6.1.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.2.0.tgz#e024d0e180b72756a83c2aaea8f25423751ba978"
dependencies:
symbol-observable "1.0.1"
tslib "^1.9.0"

safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
Expand Down Expand Up @@ -6320,12 +6324,6 @@ stream-http@^2.7.2:
to-arraybuffer "^1.0.0"
xtend "^4.0.0"

stream-to-observable@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/stream-to-observable/-/stream-to-observable-0.2.0.tgz#59d6ea393d87c2c0ddac10aa0d561bc6ba6f0e10"
dependencies:
any-observable "^0.2.0"

strict-uri-encode@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
Expand Down Expand Up @@ -6475,13 +6473,9 @@ svgo@^1.0.5:
unquote "~1.1.1"
util.promisify "~1.0.0"

[email protected]:
version "1.0.1"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4"

symbol-observable@^0.2.2:
version "0.2.4"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-0.2.4.tgz#95a83db26186d6af7e7a18dbd9760a2f86d08f40"
symbol-observable@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"

symbol-tree@^3.2.2:
version "3.2.2"
Expand Down Expand Up @@ -6638,6 +6632,10 @@ trim-right@^1.0.1:
dependencies:
glob "^6.0.4"

tslib@^1.9.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.1.tgz#a5d1f0532a49221c87755cfcc89ca37197242ba7"

[email protected]:
version "0.0.0"
resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"
Expand Down

0 comments on commit 523ee0f

Please sign in to comment.