From 82bf4ee20bea4de0eed8d94945c85891c9f59374 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 2 May 2024 18:45:19 +0300 Subject: [PATCH] Switch to flat config --- .eslintrc.json | 36 ----------------------------- eslint.config.mjs | 58 +++++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 2 ++ package.json | 4 +++- 4 files changed, 63 insertions(+), 37 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 eslint.config.mjs diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 50eef44ec..000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "root": true, - "env": { - "es6": true, - "node": true - }, - "parserOptions": { - "ecmaVersion": 2019, - "sourceType": "module" - }, - "extends": "eslint:recommended", - "rules": { - "no-return-await": "error", - "object-curly-spacing": [ - "error", - "always" - ], - "prefer-template": "error", - "semi": [ - "error", - "never" - ], - "strict": "error" - }, - "overrides": [ - { - "files": [ - "src/assets/**/*.js" - ], - "env": { - "browser": true, - "node": false - } - } - ] -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..966d976e9 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,58 @@ +import js from '@eslint/js' +import globals from 'globals' + +/** @type {import('eslint').Linter.FlatConfig[]} */ +export default [ + // global ignores + { + ignores: [ + '.cache/**', + '.netlify/**', + '_site/**', + 'node_modules/**', + 'resources/**' + ], + }, + { + languageOptions: { + ecmaVersion: 2019, + sourceType: 'module', + globals: { + ...globals.browser + } + }, + linterOptions: { + reportUnusedDisableDirectives: 'error' + } + }, + js.configs.recommended, + { + files: [ + '**/*.js', + '**/*.mjs' + ], + rules: { + 'no-return-await': 'error', + 'object-curly-spacing': [ + 'error', + 'always' + ], + 'prefer-template': 'error', + semi: [ + 'error', + 'never' + ], + strict: 'error' + } + }, + { + files: [ + 'scripts/**' + ], + languageOptions: { + globals: { + ...globals.nodeBuiltin + } + } + } +] diff --git a/package-lock.json b/package-lock.json index ffb73a7cd..2c7f09a6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,12 +9,14 @@ "version": "1.0.0", "license": "MIT", "devDependencies": { + "@eslint/js": "^9.1.1", "autoprefixer": "^10.4.19", "bootstrap": "^5.3.3", "clipboard": "^2.0.11", "cross-env": "^7.0.3", "eslint": "^9.2.0", "find-unused-sass-variables": "^6.0.0", + "globals": "^14.0.0", "hugo-bin": "^0.122.7", "linkinator": "^6.0.4", "lockfile-lint": "^4.13.2", diff --git a/package.json b/package.json index 8f4a135b6..d358cb736 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "serve": "hugo server --port 4000 --disableFastRender --noHTTPCache --renderToMemory --printPathWarnings --printUnusedTemplates", "serve-only": "npx sirv-cli _site --port 4000", "test": "npm-run-all build --parallel --continue-on-error --aggregate-output test-*", - "test-eslint": "cross-env ESLINT_USE_FLAT_CONFIG=false eslint --ignore-path .gitignore --cache --cache-location .cache/.eslintcache --report-unused-disable-directives --ext .js,.mjs .", + "test-eslint": "eslint --cache --cache-location .cache/.eslintcache .", "test-fusv": "fusv src/assets/scss/", "test-stylelint": "stylelint src/assets/scss/ --cache --cache-location .cache/.stylelintcache", "test-markdownlint": "markdownlint-cli2 \"**/*.md\" \"!**/node_modules/**\"", @@ -34,12 +34,14 @@ "netlify": "cross-env-shell HUGO_BASEURL=$DEPLOY_PRIME_URL npm run build" }, "devDependencies": { + "@eslint/js": "^9.1.1", "autoprefixer": "^10.4.19", "bootstrap": "^5.3.3", "clipboard": "^2.0.11", "cross-env": "^7.0.3", "eslint": "^9.2.0", "find-unused-sass-variables": "^6.0.0", + "globals": "^14.0.0", "hugo-bin": "^0.122.7", "linkinator": "^6.0.4", "lockfile-lint": "^4.13.2",