Skip to content

Commit

Permalink
test: eslint setup (#981)
Browse files Browse the repository at this point in the history
* chore: eslint setup

* build: update circleci config

* build: fix circleci config
  • Loading branch information
armano2 committed Feb 8, 2020
1 parent f88f00d commit 21a91e7
Show file tree
Hide file tree
Showing 6 changed files with 1,076 additions and 614 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Expand Up @@ -29,6 +29,11 @@ commands:
- run:
name: Lint project
command: yarn lint
format:
steps:
- run:
name: Format project
command: yarn format
deps:
steps:
- run:
Expand Down Expand Up @@ -56,6 +61,7 @@ commands:
- save-cache
- build
- lint
- format
- deps
- test
run-tests:
Expand Down
4 changes: 4 additions & 0 deletions .eslintignore
@@ -0,0 +1,4 @@
lib/
coverage/
node_modules/
fixtures/
74 changes: 74 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,74 @@
module.exports = {
root: true,
plugins: ['@typescript-eslint', 'jest', 'import'],
env: {
es6: true,
node: true
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 11,
ecmaFeatures: {
jsx: false
}
},
extends: ['eslint:recommended', 'prettier'],
rules: {
// disallow non-import statements appearing before import statements
'import/first': 'error',
// Forbid import of modules using absolute paths
'import/no-absolute-path': 'error',
// disallow AMD require/define
'import/no-amd': 'error',
// Forbid mutable exports
'import/no-mutable-exports': 'error',
// Prevent importing the default as if it were named
'import/no-named-default': 'error',
// Forbid a module from importing itself
'import/no-self-import': 'error'

// Enable after https://github.com/benmosher/eslint-plugin-import/issues/1650 is fixed
// Forbid the use of extraneous packages
// 'import/no-extraneous-dependencies': [
// 'error',
// {devDependencies: ['**/*.test.js']}
// ]
},
overrides: [
{
files: ['*.ts'],
parser: '@typescript-eslint/parser',
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint'
],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',

// TODO: enable those rules?
'no-empty': 'off',
'no-var': 'off'
}
},
{
files: ['*.test.ts', '*.test.js'],
env: {
jest: true
},
extends: ['plugin:jest/recommended'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-var-requires': 'off',
// disallow non-import statements appearing before import statements
'import/first': 'off'
}
}
]
};
3 changes: 3 additions & 0 deletions .prettierignore
@@ -1,2 +1,5 @@
lib/
coverage/
node_modules/
fixtures/
CHANGELOG.md
19 changes: 14 additions & 5 deletions package.json
Expand Up @@ -12,7 +12,10 @@
"deps": "lerna run deps",
"pkg": "lerna run pkg",
"docs": "docsify serve docs",
"lint": "prettier **/*.{ts,js,json,yml,md} -l",
"lint": "eslint . --ext .js,.ts",
"lint-fix": "eslint . --ext .js,.ts --fix",
"format": "prettier **/*.{ts,js,json,yml,md} -l",
"format-fix": "prettier **/*.{ts,js,json,yml,md} --write",
"publish": "lerna publish --conventional-commits",
"reinstall": "yarn clean && yarn install",
"start": "lerna run start --stream --parallel --include-dependencies",
Expand Down Expand Up @@ -75,18 +78,24 @@
},
"devDependencies": {
"@lerna/project": "3.18.0",
"@types/node": "12.12.26",
"@types/jest": "25.1.2",
"@types/node": "12.12.26",
"@typescript-eslint/eslint-plugin": "^2.19.0",
"@typescript-eslint/parser": "^2.19.0",
"docsify-cli": "^4.4.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^23.6.0",
"husky": "4.2.1",
"jest": "25.1.0",
"lerna": "3.20.2",
"lerna-v2": "npm:lerna@2",
"lerna-v3": "npm:lerna@3",
"lint-staged": "10.0.7",
"prettier": "1.17.1",
"ts-jest": "25.2.0",
"typescript": "3.7.5",
"lerna-v2": "npm:lerna@2",
"lerna-v3": "npm:lerna@3"
"typescript": "3.7.5"
},
"husky": {
"hooks": {
Expand Down

0 comments on commit 21a91e7

Please sign in to comment.