From a9ea150b927db7d0a275ece9103218eab3e9bfa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 8 Feb 2021 18:13:30 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20Add=20eslint=20with=20ES5=20enfo?= =?UTF-8?q?rcement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure our core JS files stay ES5 compatible. Alternatively we could find a way run them through babel first, initial experiments with dukpy have sadly resulted in a blocked server, so far no clue why. Related to #3920 --- .eslintignore | 1 + .eslintrc.yaml | 22 ++++++++++++++++ .github/workflows/build.yml | 51 ++++++++++++++++++++++++------------- .pre-commit-config.yaml | 6 +++++ 4 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.yaml diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..677061a2d --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +tests/cypress/** diff --git a/.eslintrc.yaml b/.eslintrc.yaml new file mode 100644 index 000000000..1f35d73ef --- /dev/null +++ b/.eslintrc.yaml @@ -0,0 +1,22 @@ +env: + browser: true + jquery: true +parserOptions: + ecmaVersion: 5 +rules: {} +overrides: + - files: + - "src/octoprint/static/js/app/**" + rules: + es5/no-block-scoping: error + es5/no-arrow-functions: error + es5/no-default-parameters: error + es5/no-rest-parameters: error + es5/no-spread: error + es5/no-destructuring: error + es5/no-for-of: error + es5/no-generators: error + es5/no-template-literals: error + +plugins: + - eslint-plugin-es5 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee710bab7..d0ac38df5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,22 +46,6 @@ jobs: run: | pre-commit run --hook-stage manual black --all-files --show-diff-on-failure - lint-prettier: - name: ๐Ÿงน prettier - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: ๐Ÿ— Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - name: ๐Ÿ— Set up dev dependencies - run: | - pip install -e .[develop] - - name: ๐Ÿš€ Run prettier - run: | - pre-commit run --hook-stage manual prettier --all-files --show-diff-on-failure - lint-isort: name: ๐Ÿงน isort runs-on: ubuntu-latest @@ -94,6 +78,38 @@ jobs: run: | pre-commit run --hook-stage manual flake8 --all-files + lint-prettier: + name: ๐Ÿงน prettier + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: ๐Ÿ— Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: ๐Ÿ— Set up dev dependencies + run: | + pip install -e .[develop] + - name: ๐Ÿš€ Run prettier + run: | + pre-commit run --hook-stage manual prettier --all-files --show-diff-on-failure + + lint-eslint: + name: ๐Ÿงน eslint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: ๐Ÿ— Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: ๐Ÿ— Set up dev dependencies + run: | + pip install -e .[develop] + - name: ๐Ÿš€ Run eslint + run: | + pre-commit run --hook-stage manual eslint --all-files + test-unit: name: ๐Ÿงช Unit tests strategy: @@ -192,9 +208,10 @@ jobs: if: github.event_name == 'release' needs: - lint-black - - lint-prettier - lint-isort - lint-flake8 + - lint-prettier + - lint-eslint - test-unit - test-install - test-e2e diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ea54569cb..2202e8a22 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,3 +42,9 @@ repos: rev: v2.1.2 hooks: - id: prettier + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v7.19.0 + hooks: + - id: eslint + additional_dependencies: + - eslint-plugin-es5@v1.3.0