Skip to content

Commit

Permalink
Merge pull request #50 from green-code-initiative/45-invalid-option-e…
Browse files Browse the repository at this point in the history
…xt-perhaps-you-meant-c

fix(eslint): migrate to flat configuration
  • Loading branch information
AMorgaut authored Aug 21, 2024
2 parents 574a5d4 + 591d893 commit df4807b
Show file tree
Hide file tree
Showing 14 changed files with 282 additions and 161 deletions.
25 changes: 0 additions & 25 deletions .eslintrc.cjs

This file was deleted.

63 changes: 63 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";

import js from "@eslint/js";
import { includeIgnoreFile } from "@eslint/compat";

import markdown from 'eslint-plugin-markdown'
import vue from 'eslint-plugin-vue'
import prettier from "eslint-config-prettier";
import ecocode from '@ecocode/eslint-plugin'

import playwright from 'eslint-plugin-playwright'
import storybook from 'eslint-plugin-storybook'

// Safely retrieve the .gitignore path
// see https://eslint.org/docs/latest/use/configure/ignore#including-gitignore-files
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, ".gitignore");


// patch ecocode plugin for flat config support
// see https://eslint.org/docs/latest/extend/plugin-migration-flat-config
if (!ecocode.configs['flat/recommended']) {
ecocode.meta = {
name: "@ecocode/eslint-plugin",
version: "1.5.0"
}
ecocode.configs['flat/recommended'] = {
plugins: {
'@ecocode': ecocode
},
rules: ecocode.configs.recommended.rules,
};
}

export default [
includeIgnoreFile(gitignorePath),
prettier,
{
files: ["**/*.vue", "**/*.js"],
languageOptions: {
ecmaVersion: 'latest',
sourceType: "module",
globals: {
...globals.node, // probably to be removed - allow node for node.process in main.js sonar-i18n.js
}
},
},
js.configs.recommended,
...markdown.configs.recommended,
...vue.configs['flat/recommended'],
ecocode.configs['flat/recommended'],
{
...storybook.configs['plugin:storybook/recommended'],
files: ['**/*.stories.js'],
},
{
...playwright.configs['flat/recommended'],
files: ['e2e/**/*.spec.js'],
},
]
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"serve:sonar": "node src/api/sonar/mock/server.js",
"sonar": "pnpm coverage && pnpm exec sonar-scanner -Dsonar.login=$SONAR",
"test:e2e": "playwright test",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
"lint": "eslint . --fix",
"format": "prettier --write src/",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
Expand All @@ -32,8 +32,9 @@
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@ecocode/eslint-plugin": "^1.5.0",
"@eslint/compat": "^1.1.1",
"@eslint/js": "^9.8.0",
"@playwright/test": "^1.44.1",
"@rushstack/eslint-patch": "^1.10.3",
"@storybook/addon-a11y": "^8.1.10",
"@storybook/addon-coverage": "^1.0.4",
"@storybook/addon-essentials": "^8.1.10",
Expand All @@ -45,13 +46,15 @@
"@storybook/vue3-vite": "^8.1.10",
"@vitejs/plugin-vue": "^5.0.5",
"@vitest/coverage-v8": "^1.6.0",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/test-utils": "^2.4.6",
"axe-playwright": "^2.0.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-markdown": "^5.1.0",
"eslint-plugin-playwright": "^1.6.2",
"eslint-plugin-storybook": "^0.8.0",
"eslint-plugin-vue": "^9.27.0",
"globals": "^15.9.0",
"jsdom": "^24.1.0",
"msw": "^2.3.1",
"prettier": "3.2.5",
Expand Down
Loading

0 comments on commit df4807b

Please sign in to comment.