From ee7649a8b49864af83cca2b34e6fcb75ff35cf2b Mon Sep 17 00:00:00 2001 From: Samuel FORESTIER Date: Wed, 24 Apr 2024 23:01:01 +0200 Subject: [PATCH] Migrates ESLint configuration to new (9+) "flat format" --- .eslint.config.mjs | 36 ++++++++++++++++++++++++++++ .eslintrc.yml | 45 ----------------------------------- .github/workflows/linting.yml | 6 ++--- 3 files changed, 38 insertions(+), 49 deletions(-) create mode 100644 .eslint.config.mjs delete mode 100644 .eslintrc.yml diff --git a/.eslint.config.mjs b/.eslint.config.mjs new file mode 100644 index 0000000..6e914ca --- /dev/null +++ b/.eslint.config.mjs @@ -0,0 +1,36 @@ +// Thunderbird User.JS ESLint configuration file + +import js from "@eslint/js"; + +export default [ + js.configs.recommended, + { + rules: { + // Expect only double-quoted strings. + quotes: ["error", "double"], + + // Expect a semicolon after each statement. + semi: ["error", "always", {"omitLastInOneLineBlock": false}], + + // As project code style, don't allow tabulation nor trailing whitespaces. + "no-tabs": "error", + "no-trailing-spaces": "error", + + // Don't allow whitespace before semicolons. + "semi-spacing": ["error", {"before": false}], + + // Don't allow irregular whitespace characters in our sheet. + "no-irregular-whitespace": ["error", {"skipStrings": false, "skipComments": false}], + }, + languageOptions: { + // From + globals: { + pref: "readonly", + user_pref: "readonly", + sticky: "readonly", + locked: "readonly", + sticky_pref: "readonly", + }, + }, + }, +]; diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index b170078..0000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,45 +0,0 @@ -%YAML 1.2 ---- - -root: true - -extends: 'eslint:recommended' - -globals: - # From - pref: true - user_pref: true - sticky: true - locked: true - sticky_pref: true - -rules: - # Expect a semicolon after each statement. - semi: - - "error" - - "always" - - - omitLastInOneLineBlock: false - - # As internal code style, don't allow tabulation. - no-tabs: "error" - # ... nor trailing spaces ! - no-trailing-spaces: "error" - - # Expect only double-quoted strings. - quotes: - - "error" - - "double" - - # Don't allow whitespace before semicolons. - semi-spacing: - - "error" - - - before: false - - # Don't allow irregular whitespace characters in our sheet. - no-irregular-whitespace: - - "error" - - - skipStrings: false - skipComments: false diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 64dc95e..317cacb 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -7,13 +7,11 @@ jobs: build: name: Run ESLint on user.js runs-on: ubuntu-latest - env: - ESLINT_USE_FLAT_CONFIG: false steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 - - run: npm install -g eslint - - run: eslint user.js + - run: npm install eslint @eslint/js + - run: npx eslint -c .eslint.config.mjs user.js