From 1074cbf9dab938c6bcf22f632af3da5119a70a7a Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 3 Jun 2024 17:53:57 +0200 Subject: [PATCH] eslint: used @stylistic rules --- .github/workflows/coding-style.yml | 4 ++-- eslint.config.mjs | 30 +++++++++++++++++++++++------- package.json | 7 ++++--- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.github/workflows/coding-style.yml b/.github/workflows/coding-style.yml index a27465b78..e7a10c17d 100644 --- a/.github/workflows/coding-style.yml +++ b/.github/workflows/coding-style.yml @@ -36,5 +36,5 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: npm install eslint - - run: npx eslint "src/**/*.js" + - run: npm install + - run: npx eslint diff --git a/eslint.config.mjs b/eslint.config.mjs index 1875e8c1f..d631b8864 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,21 +1,37 @@ import globals from 'globals'; import pluginJs from '@eslint/js'; +import stylistic from '@stylistic/eslint-plugin'; export default [ + { + ignores: ['*/', '!src/'], + }, + pluginJs.configs.recommended, + + stylistic.configs.customize({ + indent: 'tab', + braceStyle: '1tbs', + arrowParens: true, + semi: true, + jsx: false, + }), + { languageOptions: { ecmaVersion: 'latest', globals: globals.browser, }, + plugins: { + '@stylistic': stylistic, + }, rules: { - indent: ['error', 'tab'], - quotes: ['error', 'single'], - semi: ['error', 'always'], - 'prefer-arrow-callback': ['error'], - 'arrow-parens': ['error'], - 'arrow-spacing': ['error'], - 'no-var': ['error'], + '@stylistic/no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0 }], + '@stylistic/new-parens': ['error', 'never'], + '@stylistic/padded-blocks': 'off', + 'func-style': ['error', 'declaration', { allowArrowFunctions: true }], + 'prefer-arrow-callback': 'error', + 'no-var': 'error', }, }, ]; diff --git a/package.json b/package.json index 7ac905df2..57e2f01b8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "devDependencies": { - "@eslint/js": "^9.1.1", - "eslint": "^9.1.1", - "globals": "^15.1.0" + "@eslint/js": "^9.4.0", + "@stylistic/eslint-plugin": "^2.1.0", + "eslint": "^9.4.0", + "globals": "^15.3.0" } }