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