Skip to content

Commit fe855d8

Browse files
authored
fix(eslint): config (#2334)
* fix(eslint): confict rules Signed-off-by: Alexandre Philibeaux <[email protected]> * fix: fix eslint config rules Signed-off-by: Alexandre Philibeaux <[email protected]> --------- Signed-off-by: Alexandre Philibeaux <[email protected]>
1 parent aa94799 commit fe855d8

File tree

19 files changed

+65
-127
lines changed

19 files changed

+65
-127
lines changed

.changeset/strange-pears-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@scaleway/eslint-config-react": minor
3+
---
4+
5+
fix conflict rules apply by formatter like prettier / biome

eslint.config.mjs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ export default [
2525
defaultVersion: '18', // Default React version to use when the version you have installed cannot be detected.
2626
// If not provided, defaults to the latest React version.
2727
},
28+
'import/resolver': {
29+
typescript: {
30+
project: [
31+
'./tsconfig.json', // Root config
32+
'./packages/**/tsconfig.json',
33+
],
34+
},
35+
},
2836
},
2937
languageOptions: {
3038
globals: {
@@ -35,7 +43,6 @@ export default [
3543
...scw.map(config => ({ ...config, files: ['**/*.js'] })),
3644
{
3745
files: ['**/*.js'],
38-
3946
languageOptions: {
4047
parser: babelParser,
4148
parserOptions: {
@@ -56,7 +63,9 @@ export default [
5663
sourceType: 'script',
5764

5865
parserOptions: {
59-
project: ['tsconfig.json'],
66+
project: ['tsconfig.json', 'packages/**/tsconfig.json'],
67+
projectService: true,
68+
tsconfigRootDir: import.meta.dirname,
6069
},
6170
},
6271
},
@@ -73,7 +82,7 @@ export default [
7382
sourceType: 'script',
7483

7584
parserOptions: {
76-
project: ['tsconfig.json'],
85+
project: ['tsconfig.json', 'packages/**/tsconfig.json'],
7786
},
7887
},
7988

packages/cookie-consent/src/CookieConsentProvider/CookieConsentProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import type { SerializeOptions } from 'cookie'
21
import cookie from 'cookie'
3-
import type { PropsWithChildren } from 'react'
2+
import type { SerializeOptions } from 'cookie'
43
import {
54
createContext,
65
useCallback,
@@ -9,6 +8,7 @@ import {
98
useMemo,
109
useState,
1110
} from 'react'
11+
import type { PropsWithChildren } from 'react'
1212
import { uniq } from '../helpers/array'
1313
import { stringToHash } from '../helpers/misc'
1414
import { isCategoryKind } from './helpers'

packages/eslint-config-react/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@
4343
"eslint-config-airbnb": "19.0.4",
4444
"eslint-config-prettier": "9.1.0",
4545
"eslint-import-resolver-typescript": "3.7.0",
46-
"eslint-plugin-deprecation": "3.0.0",
4746
"eslint-plugin-eslint-comments": "3.2.0",
4847
"eslint-plugin-import": "2.31.0",
4948
"eslint-plugin-jsx-a11y": "6.10.2",
5049
"eslint-plugin-react": "7.37.2",
51-
"eslint-plugin-react-hooks": "5.0.0"
50+
"eslint-plugin-react-hooks": "5.1.0"
5251
},
5352
"peerDependencies": {
5453
"eslint": ">= 9.x"

packages/eslint-config-react/shared.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ export default [
3737
},
3838

3939
groups: [
40-
['builtin', 'external'],
40+
'builtin',
41+
'external',
4142
'internal',
4243
'parent',
4344
'sibling',
4445
'index',
46+
// "type",
4547
],
4648
'newlines-between': 'never',
4749
},

packages/eslint-config-react/stylistic.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ export default [
4141
'@stylistic/arrow-parens': 'off',
4242
'@stylistic/multiline-ternary': 'off',
4343
'@stylistic/no-trailing-spaces': 'off',
44+
'@stylistic/comma-style': 'off',
45+
'@stylistic/func-call-spacing': 'off',
46+
'@stylistic/jsx-wrap-multilines': 'off',
47+
'@stylistic/member-delimiter-style': 'off',
48+
'@stylistic/jsx-curly-brace-presence': 'off',
49+
'@stylistic/jsx-curly-newline': 'off',
50+
'@stylistic/jsx-one-expression-per-line': 'off',
51+
'@stylistic/max-statements-per-line ': 'off',
4452
// -------------------------------------- ///
4553

4654
'@stylistic/brace-style': defaultAirBnbRules['brace-style'],

packages/eslint-config-react/typescript.mjs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { fixupConfigRules } from '@eslint/compat'
22
import { FlatCompat } from '@eslint/eslintrc'
3-
import deprecation from 'eslint-plugin-deprecation'
43
import path from 'node:path'
54
import { fileURLToPath } from 'node:url'
65
import shared from './shared.mjs'
@@ -19,24 +18,27 @@ export default [
1918
'airbnb-base',
2019
'plugin:@typescript-eslint/recommended',
2120
'plugin:@typescript-eslint/recommended-requiring-type-checking',
21+
'plugin:import/recommended',
2222
'plugin:import/typescript',
2323
),
2424
),
2525
...airbnbTypescript,
2626
...shared,
2727
{
28-
plugins: {
29-
deprecation,
30-
},
31-
3228
rules: {
29+
/******* WARN ********/
30+
'@typescript-eslint/no-deprecated': 'warn',
31+
'@typescript-eslint/no-explicit-any': 'warn',
32+
'@typescript-eslint/no-redundant-type-constituents': 'warn',
33+
/***************************/
34+
35+
/******* ERROR ********/
3336
'@typescript-eslint/array-type': [
3437
'error',
3538
{
3639
default: 'array',
3740
},
3841
],
39-
4042
'@typescript-eslint/no-base-to-string': 'error',
4143
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
4244
'@typescript-eslint/no-unnecessary-condition': 'error',
@@ -57,15 +59,10 @@ export default [
5759
},
5860
},
5961
],
60-
61-
'@typescript-eslint/no-explicit-any': 'warn',
6262
'@typescript-eslint/no-unused-vars': 'error',
6363
'@typescript-eslint/consistent-type-imports': 'error',
6464
'@typescript-eslint/consistent-type-exports': 'error',
6565
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
66-
'@typescript-eslint/no-redundant-type-constituents': 'warn',
67-
'react/require-default-props': 'off',
68-
'react/prop-types': 'off',
6966

7067
'react/jsx-no-useless-fragment': [
7168
'error',
@@ -74,6 +71,13 @@ export default [
7471
},
7572
],
7673

74+
/***************************/
75+
76+
/******* OFF ********/
77+
78+
'react/require-default-props': 'off',
79+
'react/prop-types': 'off',
80+
7781
// The following rules are enabled in Airbnb config, but are already checked (more thoroughly) by the TypeScript compiler
7882
// Some of the rules also fail in TypeScript files, for example: https://github.com/typescript-eslint/typescript-eslint/issues/662#issuecomment-507081586
7983
// Rules are inspired by: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts

packages/use-dataloader/src/DataLoaderProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { ReactElement, ReactNode } from 'react'
21
import { createContext, useCallback, useContext, useMemo, useRef } from 'react'
2+
import type { ReactElement, ReactNode } from 'react'
33
import {
44
DEFAULT_MAX_CONCURRENT_REQUESTS,
55
KEY_IS_NOT_STRING_ERROR,

packages/use-i18n/src/__tests__/formatDate.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, test } from 'vitest'
2-
import type { FormatDateOptions } from '../formatDate'
32
import formatDate, { supportedFormats } from '../formatDate'
3+
import type { FormatDateOptions } from '../formatDate'
44

55
const locales = ['en', 'fr', 'de', 'ro', 'es']
66

packages/use-i18n/src/__tests__/formatUnit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, test } from 'vitest'
2-
import type { FormatUnitOptions } from '../formatUnit'
32
import formatUnit, { supportedUnits } from '../formatUnit'
3+
import type { FormatUnitOptions } from '../formatUnit'
44

55
const locales = ['en', 'fr', 'ro']
66

packages/use-i18n/src/formatters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { NumberFormatOptions } from '@formatjs/ecma402-abstract'
2-
import type { Cache } from '@formatjs/fast-memoize'
32
import { memoize, strategies } from '@formatjs/fast-memoize'
3+
import type { Cache } from '@formatjs/fast-memoize'
44
import IntlTranslationFormat from 'intl-messageformat'
55

66
// Deeply inspired by https://github.com/formatjs/formatjs/blob/7406e526a9c5666cee22cc2316dad1fa1d88697c/packages/intl-messageformat/src/core.ts

packages/use-i18n/src/usei18n.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import type {
77
import { formatDistanceToNow } from 'date-fns/formatDistanceToNow'
88
import { formatDistanceToNowStrict } from 'date-fns/formatDistanceToNowStrict'
99
import type { BaseLocale } from 'international-types'
10-
import type { ReactElement, ReactNode } from 'react'
1110
import {
1211
createContext,
1312
useCallback,
@@ -16,6 +15,7 @@ import {
1615
useMemo,
1716
useState,
1817
} from 'react'
18+
import type { ReactElement, ReactNode } from 'react'
1919
import dateFormat, { type FormatDateOptions } from './formatDate'
2020
import unitFormat, { type FormatUnitOptions } from './formatUnit'
2121
import formatters, { type IntlListFormatOptions } from './formatters'

packages/use-query-params/src/__tests__/index.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { act, renderHook } from '@testing-library/react'
2-
import type { History } from 'history'
32
import { createMemoryHistory } from 'history'
4-
import type { ReactNode } from 'react'
3+
import type { History } from 'history'
54
import { useLayoutEffect, useState } from 'react'
5+
import type { ReactNode } from 'react'
66
import { MemoryRouter, Router } from 'react-router-dom'
77
import { describe, expect, it, test } from 'vitest'
88
import useQueryParams from '..'

packages/use-segment/src/__tests__/SegmentProvider.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Context } from '@segment/analytics-next'
21
import { AnalyticsBrowser } from '@segment/analytics-next'
2+
import type { Context } from '@segment/analytics-next'
33
import { render, screen, waitFor } from '@testing-library/react'
44
import { describe, expect, it, vi } from 'vitest'
55
import SegmentProvider from '..'

packages/use-segment/src/__tests__/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Context } from '@segment/analytics-next'
21
import { AnalyticsBrowser } from '@segment/analytics-next'
2+
import type { Context } from '@segment/analytics-next'
33
import { renderHook, waitFor } from '@testing-library/react'
44
import type { ReactNode } from 'react'
55
import { beforeEach, describe, expect, it, vi } from 'vitest'

packages/use-segment/src/useSegment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import type {
44
AnalyticsBrowserSettings,
55
InitOptions,
66
} from '@segment/analytics-next'
7-
import type { ReactNode } from 'react'
87
import { createContext, useContext, useMemo, useState } from 'react'
8+
import type { ReactNode } from 'react'
99
import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect'
1010

1111
export type OnEventError = (error: Error) => Promise<void> | void

packages/validate-icu-locales/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
22

3+
import * as fs from 'fs/promises'
34
import { parse } from '@formatjs/icu-messageformat-parser'
45
import type { ParserError } from '@formatjs/icu-messageformat-parser/error'
5-
import * as fs from 'fs/promises'
66
import { globby } from 'globby'
77
import { importFromString } from 'module-from-string'
88

0 commit comments

Comments
 (0)