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

fix: update eslint to v9 #851

Merged
merged 2 commits into from
Sep 17, 2024
Merged
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
11 changes: 0 additions & 11 deletions .eslintignore

This file was deleted.

133 changes: 0 additions & 133 deletions .eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion cypress/fixtures/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { MockItem } from './mockTypes';
import { mockPublicTag } from './tags';

// mock an app with the graasp link
// eslint-disable-next-line import/prefer-default-export
export const GRAASP_APP_ITEM: AppItemType = AppItemFactory({
id: 'baefbd2a-5688-11eb-ae91-0242ac130002',
name: 'graasp app',
Expand Down
1 change: 0 additions & 1 deletion cypress/fixtures/useCases/staticElectricity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { CURRENT_USER } from '../members';
import { MockItem } from '../mockTypes';
import { mockItemTag } from '../tags';

// eslint-disable-next-line import/prefer-default-export
export const STATIC_ELECTRICITY: {
items: MockItem[];
} = {
Expand Down
1 change: 0 additions & 1 deletion cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
// eslint-disable-next-line import/no-extraneous-dependencies
import '@cypress/code-coverage/support';

import './commands';
Expand Down
188 changes: 188 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import cypressEslint from 'eslint-plugin-cypress';
import reactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

// eslint-disable-next-line no-underscore-dangle
const __filename = fileURLToPath(import.meta.url);
// eslint-disable-next-line no-underscore-dangle
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: [
'**/build',
'**/public',
'**/coverage',
'**/node_modules',
'.yarn/.cache',
'**/.husky',
'**/.nyc_output',
'**/.yarn',
'**/commitlint.config.cjs',
],
},
...fixupConfigRules(
compat.extends(
'airbnb',
'plugin:import/typescript',
'prettier',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'eslint:recommended',
),
),
{
plugins: {
'@typescript-eslint': fixupPluginRules(typescriptEslint),
'react-hooks': fixupPluginRules(reactHooks),
cypress: fixupConfigRules(cypressEslint),
},

languageOptions: {
globals: {
...globals.browser,
...globals.mocha,
...globals.jest,
cy: true,
Cypress: true,
JSX: 'readonly',
},

parser: tsParser,
ecmaVersion: 'latest',
sourceType: 'module',

parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},

settings: {
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],

'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},

'import/resolver': {
typescript: {
alwaysTryTypes: true,
},

node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},

rules: {
'import/order': 'off',

'react/function-component-definition': [
2,
{
namedComponents: 'arrow-function',
},
],

'import/extensions': 'off',
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
'no-unused-vars': 'off',

'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],

'@typescript-eslint/explicit-module-boundary-types': [
'error',
{
allowHigherOrderFunctions: true,
},
],

'react/jsx-filename-extension': [
1,
{
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
],

'import/no-named-as-default': 'off',

'react/static-property-placement': [
'error',
'property assignment',
{
childContextTypes: 'static public field',
contextTypes: 'static public field',
contextType: 'static public field',
defaultProps: 'static public field',
displayName: 'static public field',
propTypes: 'static public field',
},
],

'no-restricted-syntax': 'off',
'react/state-in-constructor': ['error', 'never'],

'no-console': [
'error',
{
allow: ['error', 'info'],
},
],

'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],

'react/prop-types': 'off',
'react/require-default-props': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
{
files: ['**/*.ts', '**/*.tsx'],

rules: {
'@typescript-eslint/explicit-module-boundary-types': [
'error',
{
allowHigherOrderFunctions: true,
},
],
},
},
{
files: ['src/**/*.js', 'src/**/*.tsx', 'src/**/*.ts'],

rules: {
'no-restricted-syntax': ['error'],
},
},
];
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
"devDependencies": {
"@commitlint/config-conventional": "19.5.0",
"@cypress/code-coverage": "3.12.48",
"@eslint/compat": "1.1.1",
"@eslint/eslintrc": "3.1.0",
"@eslint/js": "9.10.0",
"@trivago/prettier-plugin-sort-imports": "4.3.0",
"@types/katex": "^0.16.7",
"@types/lodash.isarray": "^4.0.9",
Expand All @@ -89,14 +92,16 @@
"cypress-iframe": "1.0.1",
"cypress-vite": "1.5.0",
"env-cmd": "10.1.0",
"eslint": "^8.57.0",
"eslint": "^9.10.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript": "3.6.3",
"eslint-plugin-cypress": "3.5.0",
"eslint-plugin-import": "2.30.0",
"eslint-plugin-jsx-a11y": "6.10.0",
"eslint-plugin-react": "7.36.1",
"eslint-plugin-react-hooks": "4.6.2",
"globals": "15.9.0",
"http-status-codes": "2.3.0",
"husky": "9.1.6",
"prettier": "3.3.3",
Expand Down
1 change: 0 additions & 1 deletion src/utils/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ const buildItemsTree = (
return tree;
};

// eslint-disable-next-line import/prefer-default-export
export const getItemTree = (
data: DiscriminatedItem[],
rootItems: DiscriminatedItem[],
Expand Down
Loading