lint: use eslint with a browserslist configuration

This commit is contained in:
David Larlet 2024-01-29 14:13:03 -05:00
parent 20998f05be
commit 65f1cdd6b4
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD
7 changed files with 1759 additions and 68 deletions

11
.eslintrc.json Normal file
View file

@ -0,0 +1,11 @@
{
"plugins": ["compat"],
"extends": ["plugin:compat/recommended"],
"env": {
"es6": true
},
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
}
}

View file

@ -2,9 +2,9 @@ name: Test & Docs
on: on:
push: push:
branches: [ master ] branches: [master]
pull_request: pull_request:
branches: [ master ] branches: [master]
jobs: jobs:
tests: tests:
@ -24,57 +24,58 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
python-version: ["3.8", "3.12"] python-version: ['3.8', '3.12']
database: [postgresql] database: [postgresql]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4 uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
cache: 'pip' cache: 'pip'
cache-dependency-path: '**/pyproject.toml' cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies - name: Install dependencies
run: | run: |
sudo apt update sudo apt update
sudo apt install libgdal-dev sudo apt install libgdal-dev
python -m pip install --upgrade pip python -m pip install --upgrade pip
make develop installjs vendors make develop installjs vendors
- name: run tests - name: run tests
run: make test run: make test
env: env:
DJANGO_SETTINGS_MODULE: 'umap.tests.settings' DJANGO_SETTINGS_MODULE: 'umap.tests.settings'
UMAP_SETTINGS: 'umap/tests/settings.py' UMAP_SETTINGS: 'umap/tests/settings.py'
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v4 uses: actions/setup-python@v4
with: with:
python-version: "3.11" python-version: '3.11'
- name: Install dependencies - name: Install dependencies
run: | run: |
python3 -m pip install -e .[test,dev] python3 -m pip install -e .[test,dev]
make installjs
- name: Run Lint - name: Run Lint
run: make lint run: make lint
- name: Run Docs - name: Run Docs
run: make docs run: make docs
docs: docs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v4 uses: actions/setup-python@v4
with: with:
python-version: "3.11" python-version: '3.11'
- name: Install dependencies - name: Install dependencies
run: | run: |
python3 -m pip install -r docs/requirements.txt python3 -m pip install -r docs/requirements.txt
- name: Run Docs - name: Run Docs
run: mkdocs build run: mkdocs build

View file

@ -20,9 +20,10 @@ format: ## Format the code and templates files
.PHONY: lint .PHONY: lint
lint: ## Lint the code and template files lint: ## Lint the code and template files
npx eslint umap/static/umap/ &&\
djlint umap/templates --lint &&\ djlint umap/templates --lint &&\
isort --check --profile black umap/ &&\ isort --check --profile black umap/ &&\
ruff format --check --target-version=py38 umap/ &&\ ruff format --check --target-version=py38 umap/ &&\
vermin --no-tips --violations -t=3.8- umap/ vermin --no-tips --violations -t=3.8- umap/
docs: ## Compile the docs docs: ## Compile the docs

1715
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,8 @@
}, },
"devDependencies": { "devDependencies": {
"chai": "^3.3.0", "chai": "^3.3.0",
"eslint": "^8.56.0",
"eslint-plugin-compat": "^4.2.0",
"happen": "~0.1.3", "happen": "~0.1.3",
"lebab": "^3.2.1", "lebab": "^3.2.1",
"mocha": "^10.2.0", "mocha": "^10.2.0",
@ -60,5 +62,8 @@
"simple-statistics": "^7.8.3", "simple-statistics": "^7.8.3",
"togpx": "^0.5.4", "togpx": "^0.5.4",
"tokml": "0.4.0" "tokml": "0.4.0"
} },
"browserslist": [
"> 0.5%, last 2 versions, Firefox ESR, not dead, not op_mini all"
]
} }

View file

@ -548,6 +548,7 @@ L.U.Help = L.Class.extend({
label.title = label.textContent = L._('Close') label.title = label.textContent = L._('Close')
this.content = L.DomUtil.create('div', 'umap-help-content', this.box) this.content = L.DomUtil.create('div', 'umap-help-content', this.box)
this.isMacOS = /mac/i.test( this.isMacOS = /mac/i.test(
// eslint-disable-next-line compat/compat -- Fallback available.
navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform
) )
}, },

View file

@ -7,7 +7,6 @@
"after": true, "after": true,
"it": true, "it": true,
"sinon": true, "sinon": true,
"qs": true,
"enableEdit": true, "enableEdit": true,
"disableEdit": true, "disableEdit": true,
"changeInputValue": true, "changeInputValue": true,