diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml new file mode 100644 index 00000000..0692cbd1 --- /dev/null +++ b/.github/workflows/eslint.yml @@ -0,0 +1,42 @@ +name: Linter +on: pull_request +jobs: + ESLint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 12 + - id: files + uses: jitterbit/get-changed-files@v1 + + - name: Run checks + run: | + for files in ${{ steps.files.outputs.added_modified }}; do + extension="${files##*.}" + if [[ $extension == 'js' || $extension == 'ts' || $extension == 'jsx' || $extension == 'tsx' ]]; then + changed_files_eslint+=" ${files}" + fi + done + + if [[ ! -z ${changed_files_eslint} ]]; then + for package_files in `find -maxdepth 2 -name "package.json" -type f`; do + cd $(dirname $package_files) && npm ci && cd ${{ github.workspace }} + done + npm install eslint-detailed-reporter --save-dev + mkdir -p eslint_report + + echo "ESLint version: "`npx eslint --version` + echo "The files will be checked: "`echo ${changed_files_eslint}` + npx eslint ${changed_files_eslint} -f node_modules/eslint-detailed-reporter/lib/detailed.js -o ./eslint_report/eslint_checks.html + else + echo "No files with the \"js|ts|jsx|tsx\" extension found" + fi + + - name: Upload artifacts + if: failure() + uses: actions/upload-artifact@v2 + with: + name: eslint_report + path: eslint_report diff --git a/cvat-ui/.eslintrc.js b/cvat-ui/.eslintrc.js index 62da6905..0c726f04 100644 --- a/cvat-ui/.eslintrc.js +++ b/cvat-ui/.eslintrc.js @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020-2021 Intel Corporation // // SPDX-License-Identifier: MIT @@ -10,6 +10,7 @@ module.exports = { parser: '@typescript-eslint/parser', ecmaVersion: 6, project: './tsconfig.json', + tsconfigRootDir: __dirname, }, plugins: ['@typescript-eslint', 'import'], extends: [ @@ -19,6 +20,7 @@ module.exports = { 'plugin:import/warnings', 'plugin:import/typescript', ], + ignorePatterns: ['.eslintrc.js'], rules: { '@typescript-eslint/indent': ['warn', 4], '@typescript-eslint/lines-between-class-members': 0,