Skip to content

Commit

Permalink
migrate to eslint 9 and lint in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev committed Oct 17, 2024
1 parent b2d2487 commit f3da41c
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 76 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

67 changes: 0 additions & 67 deletions .eslintrc.json

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ name: 'CI'
on: [pull_request, push]

jobs:
lint:
runs-on: ubuntu-latest
name: Lint

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint


swig:
runs-on: ubuntu-latest
name: Generate the SWIG wrappers
Expand Down
80 changes: 80 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import mocha from 'eslint-plugin-mocha';
import globals from 'globals';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: ['test/browser/build/*', 'build/*', 'lib/binding/*'],
}, ...compat.extends('eslint:recommended'), {
plugins: {
mocha,
},

languageOptions: {
globals: {
...globals.mocha,
...globals['shared-node-browser'],
__karma__: true,
process: true,
},

ecmaVersion: 2020,
sourceType: 'module',
},

rules: {
semi: [2, 'always'],
quotes: ['error', 'single'],
},
}, ...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
).map(config => ({
...config,
files: ['test/*.ts'],
})), {
files: ['test/*.ts'],

plugins: {
'@typescript-eslint': typescriptEslint,
},

languageOptions: {
parser: tsParser,
},

rules: {
'@typescript-eslint/ban-ts-comment': 'off',
},
}, {
files: ['**/*.cjs'],

languageOptions: {
ecmaVersion: 2015,
sourceType: 'commonjs',
globals: {
...globals.node
}
},
}, {
files: ['test/browser/*.js'],

languageOptions: {
globals: {
...globals.browser,
},
},
}];
29 changes: 22 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"build:wasm": "npm run configure:wasm && npx xpm run build --config wasm",
"build:webpack": "cd test/browser && npx webpack --mode=production",
"build": "npm run build:native && npm run build:wasm",
"lint": "clang-format -i src/*.cc src/*.h && eslint test",
"lint": "npx eslint",
"dev": "cd test/browser && npx webpack serve --mode=production",
"gcov": "mkdir -p coverage && cd coverage && gcov -o ../build/Debug/obj.target/proj_js/build -o ../build/Debug/obj.target/proj_js/src ../src/* ../build/*",
"lcov": "npx c8 report --reporter=text-lcov > coverage/tests.lcov"
Expand Down Expand Up @@ -69,6 +69,8 @@
"xpm": "^0.19.1"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.12.0",
"@types/chai": "^4.3.14",
"@types/mocha": "^10.0.6",
"@types/node": "^20.12.7",
Expand All @@ -80,6 +82,7 @@
"eslint": "^9.12.0",
"eslint-plugin-mocha": "^10.5.0",
"glob": "^11.0.0",
"globals": "^15.11.0",
"karma": "^6.4.3",
"karma-chrome-launcher": "^3.2.0",
"karma-mocha": "^2.0.1",
Expand Down

0 comments on commit f3da41c

Please sign in to comment.