Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency eslint to v9 #8108

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 0 additions & 7 deletions opencti-platform/opencti-front/.eslintignore

This file was deleted.

105 changes: 0 additions & 105 deletions opencti-platform/opencti-front/.eslintrc.js

This file was deleted.

153 changes: 153 additions & 0 deletions opencti-platform/opencti-front/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import path from 'path';
import { fileURLToPath } from 'url';
import stylistic from '@stylistic/eslint-plugin';
import reactRefresh from 'eslint-plugin-react-refresh';
import globals from 'globals';
import js from '@eslint/js';
import eslintPluginImportX from 'eslint-plugin-import-x'
import reactRecommended from 'eslint-plugin-react/configs/recommended.js';
import customRules from './packages/eslint-plugin-custom-rules/lib/index.js';
import importNewlines from 'eslint-plugin-import-newlines';

// imports to not let tools report them as unused
import 'eslint-plugin-react-hooks';
import '@typescript-eslint/eslint-plugin';
import 'eslint-plugin-i18next';
import 'eslint-import-resolver-oxc';
import '@typescript-eslint/parser';

import { FlatCompat } from '@eslint/eslintrc';

// mimic CommonJS variables -- not needed if using CommonJS
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const compat = new FlatCompat({
baseDirectory: __dirname,
});

// TODO add eslint-plugin-import when https://github.com/import-js/eslint-plugin-import/issues/2556 is done

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

// rules recommended by eslint-plugin-react
{
...reactRecommended,
settings: {
react: {
version: 'detect',
},
},
},

// rules recommended by eslint-plugin-import-x
{
...eslintPluginImportX.flatConfigs.recommended,
...eslintPluginImportX.flatConfigs.typescript,
"settings": {
"import-x/resolver": "oxc"
}
},

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

// rules recommended by @typescript-eslint/eslint-plugin --- typescript-eslint to avoid compat mode
...compat.extends('plugin:@typescript-eslint/recommended'),

// rules recommended by eslint-plugin-react-hooks
// ...compat.extends('plugin:react-hooks/recommended'), WAIT FOR https://github.com/facebook/react/issues/28313

// rules recommended by eslint-plugin-i18next
...compat.extends('plugin:i18next/recommended'),

{
plugins: {
// eslint-plugin-custom-rules config
'custom-rules': customRules,
// eslint-plugin-import-newlines config
'import-newlines': importNewlines,
},
rules: {
'custom-rules/classes-rule': 1,
},
},

// other config
{
languageOptions: {
globals: {
...globals.browser,
...globals.commonjs,
...globals.es2020,
process: true,
},
},
plugins: {
'react-refresh': reactRefresh,
},
rules: {
// react-refresh rules
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],

// react rules
'react/no-unused-prop-types': 0,
'react/prop-types': 0,

// @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: '^_',
},
],

// import-newlines rules
'import-newlines/enforce': ['error', {items: 20, 'max-len': 180}],

// @stylistic rules
// '@stylistic/arrow-parens': 'off',
// '@stylistic/quote-props': ['error', 'as-needed'],
// '@stylistic/brace-style': ['error', '1tbs'],

'import-x/no-cycle': 'error',
},
},

// 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',
],
},
];
22 changes: 14 additions & 8 deletions opencti-platform/opencti-front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@
"yup": "1.4.0"
},
"devDependencies": {
"@eslint/js": "9.11.0",
"@playwright/test": "1.45.3",
"@rollup/plugin-graphql": "2.0.4",
"@stylistic/eslint-plugin": "2.8.0",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "16.0.0",
Expand All @@ -112,24 +114,28 @@
"@types/relay-runtime": "17.0.4",
"@types/relay-test-utils": "17.0.0",
"@types/uuid": "10.0.0",
"@typescript-eslint/eslint-plugin": "8.5.0",
"@typescript-eslint/parser": "8.5.0",
"@vitejs/plugin-react": "4.3.1",
"babel-plugin-relay": "17.0.0",
"chokidar": "3.6.0",
"compression": "1.7.4",
"cross-env": "7.0.3",
"esbuild": "0.23.1",
"esbuild-jest": "0.5.0",
"eslint": "8.57.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.11.0",
"eslint-import-resolver-oxc": "0.3.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-import-newlines": "1.4.0",
"eslint-plugin-react": "7.35.0",
"eslint-plugin-import-x": "4.2.1",
"eslint-plugin-playwright": "1.6.2",
"eslint-plugin-react": "7.35.2",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-react-refresh": "0.4.11",
"express": "4.20.0",
"fs-extra": "11.2.0",
"globals": "15.9.0",
"http-proxy-middleware": "3.0.0",
"i18n-auto-translation": "1.6.2",
"jsdom": "24.1.1",
Expand All @@ -153,7 +159,7 @@
"esbuild": "node builder/prod/prod.js",
"build": "yarn relay && yarn esbuild",
"build:standalone": "yarn relay && yarn esbuild --keep",
"lint": "cross-env DEBUG=eslint:cli-engine TIMING=1 eslint --max-warnings 0 --cache -c .eslintrc.js src",
"lint": "cross-env DEBUG=eslint:cli-engine TIMING=1 eslint --max-warnings 0 --cache src",
"control": "yarn audit --groups dependencies --summary",
"test": "vitest run",
"test:watch": "vitest watch",
Expand Down
Loading