Skip to content

Commit

Permalink
Enforce Prettier defaults + also format .babelrc and .json (babel#7499)
Browse files Browse the repository at this point in the history
* .prettierrc: full configuration for Prettier

This way, contributors using different-from-default settings will still
use the correct prettier settings

* Makefile: also lint .babelrc.js

* Makefile: also prettify .json files

* Exclude package.json files and correct build dir

* Add more default options to prettierrc and load it in cli

This avoids prettier looking up the config for each file

* Format json

* Update prettier and eslint and reformat codebase

* Remove obsolete file

* Add comment
  • Loading branch information
danez authored Mar 6, 2018
1 parent 50b9fbb commit c8992e4
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 89 deletions.
8 changes: 4 additions & 4 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const envOpts = {
loose: true,
};

switch(env) {
switch (env) {
case "development":
envOpts.debug = true;
// fall-through
// fall-through
case "test":
case "cov":
envOpts.targets = {
node: "current"
};
node: "current",
};
}

const config = {
Expand Down
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/lib
/build
package.json
packages/babel-runtime
!packages/babel-runtime/scripts
!packages/babel-runtime/core-js.js
Expand All @@ -18,5 +20,4 @@ packages/babel-preset-env-standalone/babel-preset-env.js
packages/babel-preset-env-standalone/babel-preset-env.min.js
packages/babel-standalone/babel.js
packages/babel-standalone/babel.min.js
packages/babylon/build
packages/babylon/test/expressions
9 changes: 2 additions & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"root": true,
"extends": "babel",
"plugins": [
"prettier"
],
"plugins": ["prettier"],
"rules": {
"curly": ["error", "multi-line"],
"prettier/prettier": "error",
Expand All @@ -14,10 +12,7 @@
},
"overrides": [
{
"files": [
"packages/*/src/**/*.js",
"codemods/*/src/**/*.js"
],
"files": ["packages/*/src/**/*.js", "codemods/*/src/**/*.js"],
"rules": {
"no-undefined-identifier": "error",
"no-deprecated-clone": "error"
Expand Down
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"arrowParens": "avoid",
"trailingComma": "es5",
"useTabs": false,
"semi": true,
"singleQuote": false,
"bracketSpacing": true,
"jsxBracketSameLine": false,
"tabWidth": 2,
"parser": "babylon",
"printWidth": 80,
"overrides": [{
"files": [
"**/codemods/*/src/**/*.js",
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ flow:
./node_modules/.bin/flow check --strip-root

lint:
./node_modules/.bin/eslint scripts $(SOURCES) *.js --format=codeframe --rulesdir="./scripts/eslint_rules"
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' '**/.*.js' --format=codeframe --rulesdir="./scripts/eslint_rules"

fix:
./node_modules/.bin/eslint scripts $(SOURCES) *.js --format=codeframe --fix --rulesdir="./scripts/eslint_rules"
# The config is hardcoded because otherwise prettier searches for it and also picks up some broken package.json files from tests
./node_modules/.bin/prettier --config .prettierrc --write --ignore-path .eslintignore '**/*.json'
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' '**/.*.js' --format=codeframe --fix --rulesdir="./scripts/eslint_rules"

clean: test-clean
rm -rf packages/babel-polyfill/browser*
Expand Down
15 changes: 3 additions & 12 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,10 @@
"cacheDir": ".changelog",
"commands": {
"publish": {
"ignore": [
"*.md",
"test/**",
"codemods/**"
]
"ignore": ["*.md", "test/**", "codemods/**"]
}
},
"packages": [
"packages/*",
"codemods/*"
],
"packages": ["packages/*", "codemods/*"],
"npmClient": "yarn",
"npmClientArgs": [
"--no-lockfile"
]
"npmClientArgs": ["--no-lockfile"]
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
"browserify": "^13.1.1",
"bundle-collapser": "^1.2.1",
"chai": "^4.1.0",
"chalk": "^2.0.0",
"chalk": "^2.3.2",
"charcodes": "^0.1.0",
"derequire": "^2.0.2",
"enhanced-resolve": "^3.0.0",
"eslint": "^4.5.0",
"eslint": "^4.18.2",
"eslint-config-babel": "^7.0.2",
"eslint-plugin-flowtype": "^2.20.0",
"eslint-plugin-prettier": "^2.5.0",
Expand All @@ -52,7 +52,7 @@
"lodash": "^4.2.0",
"merge-stream": "^1.0.1",
"output-file-sync": "^2.0.0",
"prettier": "1.10.2",
"prettier": "1.11.1",
"pump": "^1.0.2",
"rimraf": "^2.4.3",
"rollup-plugin-babel": "^4.0.0-beta.0",
Expand Down
2 changes: 0 additions & 2 deletions test/warning.js

This file was deleted.

Loading

0 comments on commit c8992e4

Please sign in to comment.