diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-05-31 13:25:05 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-06-05 12:11:55 +0200 |
| commit | 5852c980980de53e00d76a0bdb4b41bf5c0f5b39 (patch) | |
| tree | 0323ff3b894708e2e6d108928bb27b1abf897ba6 | |
| parent | aa859cf72f0e1927dbf9362918ddb04641b59c3a (diff) | |
| download | mullvadvpn-5852c980980de53e00d76a0bdb4b41bf5c0f5b39.tar.xz mullvadvpn-5852c980980de53e00d76a0bdb4b41bf5c0f5b39.zip | |
Add javascript code formatter
| -rw-r--r-- | .eslintrc | 7 | ||||
| -rw-r--r-- | .prettierrc.yml | 12 | ||||
| -rw-r--r-- | .travis.yml | 1 | ||||
| -rw-r--r-- | app/components/AccountInput.js | 6 | ||||
| -rw-r--r-- | app/components/Switch.js | 3 | ||||
| -rw-r--r-- | package.json | 4 | ||||
| -rw-r--r-- | yarn.lock | 14 |
7 files changed, 39 insertions, 8 deletions
@@ -1,7 +1,8 @@ { "extends": [ "eslint:recommended", - "plugin:react/recommended" + "plugin:react/recommended", + "prettier" ], "parser": "babel-eslint", "parserOptions": { @@ -12,10 +13,6 @@ }, "plugins": [ "react", "flowtype" ], "rules": { - "indent": [ "error", 2 ], - "quotes": [ "error", "single" ], - "linebreak-style": [ "error", "unix" ], - "semi": [ 2, "always" ], "no-console": "off", "no-loop-func": "warn", "new-cap": "off", diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 0000000000..76a9981af2 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,12 @@ +# .prettierrc.yml +# see: https://prettier.io/docs/en/options.html +printWidth: 100 +tabWidth: 2 +semi: true +useTabs: false +singleQuote: true +trailingComma: all +bracketSpacing: true +jsxBracketSameLine: true +arrowParens: always +proseWrap: always
\ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 17afbe0c4b..c63848498f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ matrix: script: - yarn run lint - yarn run flow + - yarn run check-format - yarn test diff --git a/app/components/AccountInput.js b/app/components/AccountInput.js index dd2d3c7621..e113b1679c 100644 --- a/app/components/AccountInput.js +++ b/app/components/AccountInput.js @@ -7,7 +7,8 @@ import { colors } from '../config'; // @TODO: move it into types.js // ESLint issue: https://github.com/babel/babel-eslint/issues/445 -declare class ClipboardData { // eslint-disable-line no-unused-vars +// eslint-disable-next-line no-unused-vars +declare class ClipboardData { setData(type: string, data: string): void; getData(type: string): string; } @@ -75,7 +76,8 @@ export default class AccountInput extends React.Component<AccountInputProps, Acc render() { const displayString = formatAccount(this.state.value || ''); - const { value, onChange, onEnter, ...otherProps } = this.props; // eslint-disable-line no-unused-vars + // eslint-disable-next-line no-unused-vars + const { value, onChange, onEnter, ...otherProps } = this.props; return ( <TextInput { ...otherProps } value={ displayString } diff --git a/app/components/Switch.js b/app/components/Switch.js index 9032065e9a..6bd4b8e4d0 100644 --- a/app/components/Switch.js +++ b/app/components/Switch.js @@ -131,7 +131,8 @@ export default class Switch extends React.Component<SwitchProps, State> { } render() { - const { isOn, onChange, ...otherProps } = this.props; // eslint-disable-line no-unused-vars + // eslint-disable-next-line no-unused-vars + const { isOn, onChange, ...otherProps } = this.props; const className = ('switch ' + (otherProps.className || '')).trim(); return ( <input { ...otherProps } diff --git a/package.json b/package.json index 5bd516bb24..420e032361 100644 --- a/package.json +++ b/package.json @@ -55,11 +55,13 @@ "enzyme": "^3.2.0", "enzyme-adapter-react-16": "^1.1.0", "eslint": "^4.18.2", + "eslint-config-prettier": "^2.9.0", "eslint-plugin-flowtype": "^2.46.1", "eslint-plugin-react": "^7.7.0", "flow-bin": "^0.66.0", "flow-typed": "^2.3.0", "npm-run-all": "^4.0.1", + "prettier": "1.13.3", "react-test-renderer": "16.0.0", "redux-mock-store": "^1.3.0", "rimraf": "^2.5.4", @@ -71,6 +73,8 @@ "develop": "cross-env BABEL_ENV=electron npm run private:compile -- --source-maps true && run-p -r private:watch private:serve", "test": "cross-env BABEL_ENV=electron electron-mocha --renderer -R spec --require babel-core/register --require-main test/setup/main.js test/*.spec.js test/**/*.spec.js", "lint": "eslint --no-ignore scripts app test *.js", + "format": "prettier --write 'app/**/*.js' 'test/**/*.js'", + "check-format": "prettier --list-different 'app/**/*.js' 'test/**/*.js'", "flow": "flow", "pack": "run-s pack:mac pack:win pack:linux", "pack:mac": "cross-env BABEL_ENV=electron run-s private:clean private:compile private:build:mac && rm -r ./dist/mac", @@ -2962,6 +2962,12 @@ escodegen-wallaby@^1.6.7: optionalDependencies: source-map "~0.2.0" +eslint-config-prettier@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.9.0.tgz#5ecd65174d486c22dff389fe036febf502d468a3" + dependencies: + get-stdin "^5.0.1" + eslint-plugin-flowtype@^2.46.1: version "2.46.1" resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.46.1.tgz#c4f81d580cd89c82bc3a85a1ccf4ae3a915143a4" @@ -3623,6 +3629,10 @@ get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" +get-stdin@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-5.0.1.tgz#122e161591e21ff4c52530305693f20e6393a398" + get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -6042,6 +6052,10 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" +prettier@1.13.3: + version "1.13.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.13.3.tgz#e74c09a7df6519d472ca6febaa37cf7addb48a20" + pretty-bytes@^1.0.2: version "1.0.4" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-1.0.4.tgz#0a22e8210609ad35542f8c8d5d2159aff0751c84" |
