Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[frontend] pass to flat config
  • Loading branch information
guillaumejparis committed Oct 29, 2024
commit ba7017f40cfe24e8e6fd1e99e39426e90b30f906
12 changes: 0 additions & 12 deletions openbas-front/.eslintignore

This file was deleted.

108 changes: 0 additions & 108 deletions openbas-front/.eslintrc.cjs

This file was deleted.

165 changes: 165 additions & 0 deletions openbas-front/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
// imports to not let tools report them as unused
import 'eslint-import-resolver-oxc';

import js from '@eslint/js';
import stylistic from '@stylistic/eslint-plugin';
import i18next from 'eslint-plugin-i18next';
import importPlugin from 'eslint-plugin-import';
import playwright from 'eslint-plugin-playwright';
import react from 'eslint-plugin-react';
import reactRefresh from 'eslint-plugin-react-refresh';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import globals from 'globals';
import ts from 'typescript-eslint';

import customRules from './packages/eslint-plugin-custom-rules/lib/index.js';

export default [
// rules recommended by @eslint/js
js.configs.recommended,

// rules recommended by typescript-eslint
...ts.configs.recommended,

// rules recommended by eslint-plugin-react
react.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
{
settings: {
react: {
version: 'detect',
},
},
},

// rules recommended by eslint-plugin-import
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
{
settings: {
'import/resolver': 'oxc',
'import/ignore': [
'react-apexcharts', // ignore react-apexcharts as the default export is broken
],
},
},

// rules recommended by @stylistic/eslint-plugin
// stylistic.configs.customize({
// semi: true,
// }),

// rules recommended by eslint-plugin-i18next
i18next.configs['flat/recommended'],

// other config
{
plugins: {
// eslint-plugin-react-refresh
'react-refresh': reactRefresh,
// eslint-plugin-simple-import-sort
// 'simple-import-sort': simpleImportSort,
// local package eslint-plugin-custom-rules
'custom-rules': customRules,
},
rules: {
// react-refresh rules
'react-refresh/only-export-components': [
'warn',
{
allowConstantExport: true,
},
],

// eslint-plugin-simple-import-sort rules
// 'simple-import-sort/imports': 'error',
// 'simple-import-sort/exports': 'error',

// local package eslint-plugin-custom-rules rules
'custom-rules/classes-rule': 1,

// @typescript-eslint rules
'@typescript-eslint/naming-convention': ['error', {
selector: 'variable',
format: ['camelCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
filter: {
regex: '/([^_]*)/',
match: true,
},
}],
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-use-before-define': 'error',

// eslint-plugin-react rules
'react/prop-types': 0,

// @stylistic rules
// '@stylistic/brace-style': ['error', '1tbs'],
// '@stylistic/multiline-ternary': ['error', 'always-multiline', { ignoreJSX: true }],

// eslint-plugin-import rules
'import/no-named-as-default-member': 'off',
'import/prefer-default-export': 'error',
'import/namespace': 'off',

// custom rules inspired from airbnb
'sort-imports': 'off',
'no-underscore-dangle': 'error',
'no-await-in-loop': 'error',
'no-param-reassign': 'error',
'consistent-return': 'error',
'default-case': 'error',
'no-template-curly-in-string': 'error',
'no-bitwise': 'error',
'no-nested-ternary': 'error',
'prefer-promise-reject-errors': 'error',
'no-console': 'error',
},
languageOptions: {
globals: {
...globals.browser,
...globals.commonjs,
...globals.es2020,
process: true,
},
},
linterOptions: {
reportUnusedDisableDirectives: 'off', // to fix when eslint handle disable directive on missing rules on purpose
},
},

// tests e2e config
{
files: ['tests_e2e/**/*'],
// rules recommended by eslint-plugin-playwright
...playwright.configs['flat/recommended'],
},

// ignores patterns
{
ignores: [
'node_modules',
'coverage',
'packages',
'public',
'src/static/ext',
'builder/prod/build',
'builder/dev/build',
'__generated__',
'test-results',
'playwright-report',
'blob-report',
'playwright/.cache',
'.yarn',
],
},
];
33 changes: 16 additions & 17 deletions openbas-front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"apexcharts": "3.51.0",
"axios": "1.7.7",
"ckeditor5-custom-build": "link:packages/ckeditor5-custom-build",
"classcat": "^5.0.5",
"classcat": "5.0.5",
"classnames": "2.5.1",
"cronstrue": "2.50.0",
"d3-hierarchy": "3.1.2",
Expand Down Expand Up @@ -76,15 +76,15 @@
"uuid": "10.0.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"zod": "3.23.8",
"zustand": "^4.5.4"
"zustand": "4.5.4"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "7.25.7",
"@eslint/js": "9.11.0",
"@eslint/js": "9.13.0",
"@playwright/test": "1.48.2",
"@stylistic/eslint-plugin": "1.8.1",
"@stylistic/eslint-plugin": "2.9.0",
"@testing-library/react": "14.3.1",
"@types/d3-hierarchy": "3.1.7",
"@types/eslint__js": "8.42.3",
"@types/node": "20.17.1",
"@types/pdfmake": "0.2.9",
"@types/qs": "6",
Expand All @@ -94,30 +94,29 @@
"@types/react-syntax-highlighter": "15",
"@types/seamless-immutable": "7.1.19",
"@types/uuid": "10.0.0",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"@typescript-eslint/parser": "8.11.0",
"@vitejs/plugin-react": "4.3.0",
"chokidar": "4.0.1",
"cross-env": "7.0.3",
"esbuild": "0.24.0",
"eslint": "9.11.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "18.0.0",
"eslint-config-react-app": "7.0.1",
"eslint": "9.13.0",
"eslint-import-resolver-oxc": "0.4.0",
"eslint-plugin-custom-rules": "link:packages/eslint-plugin-custom-rules",
"eslint-plugin-i18next": "6.0.9",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-i18next": "6.1.0",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-import-newlines": "1.4.0",
"eslint-plugin-playwright": "1.6.2",
"eslint-plugin-react": "7.34.1",
"eslint-plugin-playwright": "2.0.0",
"eslint-plugin-react": "7.37.2",
"eslint-plugin-react-refresh": "0.4.13",
"eslint-plugin-simple-import-sort": "^12.1.1",
"express": "4.20.0",
"fs-extra": "11.2.0",
"globals": "15.9.0",
"jsdom": "25.0.1",
"nyc": "17.0.0",
"swagger-typescript-api": "13.0.22",
"typescript": "5.6.2",
"typescript-eslint": "8.11.0",
"vite": "5.4.7",
"vite-plugin-istanbul": "6.0.2",
"vitest": "2.1.1"
Expand All @@ -129,7 +128,7 @@
"start": "vite",
"deprecated-start": "node builder/dev/dev.js",
"build": "node builder/prod/prod.js",
"lint": "cross-env DEBUG=eslint:cli-engine TIMING=1 eslint --max-warnings 0 --cache .",
"lint": "cross-env DEBUG=eslint:cli-engine TIMING=1 eslint --max-warnings 0 --cache . --rule \"{'import/namespace': 'error', 'import/no-cycle': 'error'}\"",
"control": "yarn audit --groups dependencies --summary",
"test": "vitest run",
"check-ts": "tsc --noEmit",
Expand Down
15 changes: 0 additions & 15 deletions openbas-front/tests_e2e/.eslintrc.cjs

This file was deleted.