Skip to content

Commit

Permalink
Fix linting rule and add lint to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
torifat committed Sep 9, 2019
1 parent 04259b2 commit 6611be8
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"node": "8"
},
"useBuiltIns": "usage",
"corejs": 3,
"loose": true
}
]
Expand All @@ -25,6 +26,7 @@
"node": "4"
},
"useBuiltIns": "usage",
"corejs": 3,
"loose": true
}
]
Expand Down
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
flow-typed/
lib/
node_modules/
dist/
13 changes: 7 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module.exports = {
root: true,
env: {
es6: true,
node: true,
'jest/globals': true,
},
extends: ['eslint:recommended', 'plugin:jest/recommended', 'prettier'],
extends: [
'eslint:recommended',
'plugin:jest/recommended',
'plugin:prettier/recommended',
],
plugins: ['jest'],
parserOptions: {
ecmaVersion: 2017,
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
experimentalObjectRestSpread: true,
},
},
rules: {},
};
19 changes: 19 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,22 @@ jobs:
if: matrix.node-version == '12.x'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Use Node.js 10.x
uses: actions/setup-node@v1
with:
node-version: 10.x

- name: Install Yarn
run: curl -o- -L https://yarnpkg.com/install.sh | bash

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Run ESLint
run: yarn eslint .
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"eslint": "^6.3.0",
"eslint-config-prettier": "^6.2.0",
"eslint-plugin-jest": "^22.17.0",
"eslint-plugin-prettier": "^3.1.0",
"flow-bin": "^0.107.0",
"husky": "^3.0.5",
"jest": "^24.9.0",
Expand All @@ -59,7 +60,7 @@
"build": "yarn run clean && yarn build:modern && yarn build:legacy",
"build:modern": "BABEL_ENV=modern babel src -d lib/modern/",
"build:legacy": "BABEL_ENV=legacy babel src -d lib/legacy",
"prepare": "yarn build",
"prepublishOnly": "yarn build",
"format": "prettier --write src/*.js src/**/*.js",
"test": "jest",
"test-ci": "jest --coverage --colors"
Expand All @@ -68,9 +69,5 @@
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.js"
]
},
"prettier": {
"singleQuote": true,
"trailingComma": "es5"
}
}
4 changes: 1 addition & 3 deletions src/validation-errors/additional-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export default class AdditionalPropValidationError extends BaseValidationError {

return output.concat(
this.getCodeFrame(
chalk`😲 {magentaBright ${
params.additionalProperty
}} is not expected to be here!`,
chalk`😲 {magentaBright ${params.additionalProperty}} is not expected to be here!`,
`${dataPath}/${params.additionalProperty}`
)
);
Expand Down
4 changes: 2 additions & 2 deletions src/validation-errors/enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export default class EnumValidationError extends BaseValidationError {
value,
weight: leven(value, currentValue.toString()),
}))
.sort(
(x, y) => (x.weight > y.weight ? 1 : x.weight < y.weight ? -1 : 0)
.sort((x, y) =>
x.weight > y.weight ? 1 : x.weight < y.weight ? -1 : 0
)[0];

return allowedValues.length === 1 ||
Expand Down
19 changes: 19 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,13 @@ eslint-plugin-jest@^22.17.0:
dependencies:
"@typescript-eslint/experimental-utils" "^1.13.0"

eslint-plugin-prettier@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.0.tgz#8695188f95daa93b0dc54b249347ca3b79c4686d"
integrity sha512-XWX2yVuwVNLOUhQijAkXz+rMPPoCr7WFiAl8ig6I7Xn+pPVhDhzg4DxHpmbeb0iqjO9UronEA3Tb09ChnFVHHA==
dependencies:
prettier-linter-helpers "^1.0.0"

eslint-scope@^4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848"
Expand Down Expand Up @@ -1994,6 +2001,11 @@ fast-deep-equal@^2.0.1:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"
integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=

fast-diff@^1.1.2:
version "1.2.0"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==

fast-json-stable-stringify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"
Expand Down Expand Up @@ -3943,6 +3955,13 @@ prelude-ls@~1.1.2:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=

prettier-linter-helpers@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b"
integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==
dependencies:
fast-diff "^1.1.2"

prettier@^1.14.2:
version "1.18.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea"
Expand Down

0 comments on commit 6611be8

Please sign in to comment.