Skip to content

Commit

Permalink
Use ESLint instead of TSLint (#317)
Browse files Browse the repository at this point in the history
* Use ESLint instead of TSLint

* Allow quotes in jsx
  • Loading branch information
czgu authored Nov 17, 2020
1 parent eb3c1dc commit 3c72982
Show file tree
Hide file tree
Showing 201 changed files with 3,214 additions and 2,460 deletions.
253 changes: 253 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
module.exports = {
settings: {
react: {
version: 'detect',
},
},
env: {
browser: true,
es6: true,
},
extends: [
'plugin:react/recommended',
'prettier',
'prettier/@typescript-eslint',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: [
'eslint-plugin-import',
'eslint-plugin-react',
'eslint-plugin-prefer-arrow',
'eslint-plugin-jsdoc',
'@typescript-eslint',
'@typescript-eslint/tslint',
],
rules: {
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': [
'error',
{
default: 'array-simple',
},
],
'@typescript-eslint/ban-types': [
'error',
{
types: {
Object: {
message:
'Avoid using the `Object` type. Did you mean `object`?',
},
Function: {
message:
'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.',
},
Boolean: {
message:
'Avoid using the `Boolean` type. Did you mean `boolean`?',
},
Number: {
message:
'Avoid using the `Number` type. Did you mean `number`?',
},
String: {
message:
'Avoid using the `String` type. Did you mean `string`?',
},
Symbol: {
message:
'Avoid using the `Symbol` type. Did you mean `symbol`?',
},
},
},
],
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'explicit',
},
],
'@typescript-eslint/member-delimiter-style': [
'off',
{
multiline: {
delimiter: 'none',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
},
],
'@typescript-eslint/member-ordering': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: ['method', 'function'],
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
},
],
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'off',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/semi': ['off', null],
'@typescript-eslint/triple-slash-reference': [
'error',
{
path: 'always',
types: 'prefer-import',
lib: 'always',
},
],
'@typescript-eslint/tslint/config': [
'error',
{
rules: {
'prefer-conditional-expression': true,
},
},
],
'@typescript-eslint/unified-signatures': 'error',
// '@typescript-eslint/no-shadow': ['error'],
'arrow-body-style': 'error',
'arrow-parens': ['off', 'always'],
'brace-style': ['off', 'off'],
complexity: 'off',
'constructor-super': 'error',
curly: 'error',
eqeqeq: ['error', 'smart'],
'guard-for-in': 'error',
'id-blacklist': [
'error',
'any',
'Number',
'number',
'String',
'string',
'Boolean',
'boolean',
'Undefined',
'undefined',
],
'id-match': 'error',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: false,
},
],
'import/no-internal-modules': 'off',
'import/order': 'off',
'jsdoc/check-alignment': 'error',
'jsdoc/check-indentation': 'error',
'jsdoc/newline-after-description': 'error',
'max-classes-per-file': 'off',
'no-bitwise': 'error',
'no-caller': 'error',
'no-cond-assign': 'error',
'no-console': 'off',
'no-debugger': 'error',
'no-duplicate-case': 'error',
'no-duplicate-imports': 'error',
'no-empty': 'error',
'no-eval': 'error',
'no-extra-bind': 'error',
'no-fallthrough': 'off',
'no-invalid-this': 'off',
'no-irregular-whitespace': 'off',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-redeclare': 'error',
'no-return-await': 'error',
'no-sequences': 'error',
'no-shadow': 'off',
'no-sparse-arrays': 'error',
'no-template-curly-in-string': 'error',
'no-throw-literal': 'error',
'no-undef-init': 'error',
'no-underscore-dangle': 'off',
'no-unsafe-finally': 'error',
'no-unused-labels': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'one-var': ['error', 'never'],
'prefer-arrow/prefer-arrow-functions': [
'error',
{ allowStandaloneDeclarations: true },
],
'prefer-const': 'error',
'prefer-object-spread': 'error',
radix: 'error',
'react/display-name': 'off',
'react/jsx-boolean-value': 'off',
'react/jsx-curly-spacing': 'off',
'react/jsx-equals-spacing': 'off',
'react/jsx-key': 'error',
'react/jsx-no-bind': [
'error',
{ allowArrowFunctions: true, allowBind: true },
],
'react/jsx-no-comment-textnodes': 'error',
'react/jsx-no-duplicate-props': 'error',
'react/jsx-no-target-blank': 'error',
'react/jsx-no-undef': 'error',
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/jsx-wrap-multilines': 'off',
'react/no-children-prop': 'error',
'react/no-danger-with-children': 'error',
'react/no-deprecated': 'error',
'react/no-direct-mutation-state': 'error',
'react/no-find-dom-node': 'error',
'react/no-is-mounted': 'error',
'react/no-render-return-value': 'error',
'react/no-string-refs': 'error',
'react/no-unescaped-entities': ['error', { forbid: ['>', '}'] }],
'react/no-unknown-property': 'error',
'react/no-unsafe': 'off',
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'error',
'react/require-render-return': 'error',
'react/self-closing-comp': [
'error',
{
component: true,
html: true,
},
],
'space-in-parens': ['off', 'never'],
'spaced-comment': [
'error',
'always',
{
markers: ['/'],
},
],
'use-isnan': 'error',
'valid-typeof': 'off',
},
};
76 changes: 38 additions & 38 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
name: Tests
on:
push:
branches:
- master
pull_request:
push:
branches:
- master
pull_request:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
lint:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# This workflow contains a single job called "build"
lint:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Set PY
run: |
echo 'PY<<EOF' >> $GITHUB_ENV
echo "$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: pre-commit/action@v1.0.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Run docker test
run: make unit_test
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Set PY
run: |
echo 'PY<<EOF' >> $GITHUB_ENV
echo "$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: pre-commit/action@v1.0.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Run docker test
run: make test
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ remove_running_dev_image:
$(eval RUNNING_CONTAINERS=$(shell sh -c 'docker ps -q --filter name=datahub_devserver'))
docker kill $(RUNNING_CONTAINERS) || true

unit_test: dev_image
test: dev_image
docker-compose --file containers/docker-compose.test.yml up --abort-on-container-exit

clean: clean_pyc clean_docker
Expand Down
2 changes: 1 addition & 1 deletion containers/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ services:
test:
container_name: datahub_test
image: datahub-dev:latest
command: './datahub/scripts/run_unit_test'
command: './datahub/scripts/run_test'
8 changes: 7 additions & 1 deletion datahub/scripts/run_unit_test → datahub/scripts/run_test
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ run_js_unit_test() {

run_ts_validation() {
echo 'Start running ts validation >>>>>>>>>>>>>>>>>>>>>>>>>>>>'
./node_modules/.bin/tsc --noEmit
npm run tsc-check
}

run_eslint_validation() {
echo 'Start running eslint validation >>>>>>>>>>>>>>>>>>>>>>>>>>>>'
npm run lint
}

tests=(
"run_python_unit_test"
"run_ts_validation"
"run_js_unit_test"
"run_eslint_validation"
"run_webpack_test"
)

Expand Down
Loading

0 comments on commit 3c72982

Please sign in to comment.