Skip to content

Commit 28835bf

Browse files
style: update eslint.config.mjs and fix lint
1 parent 07913d7 commit 28835bf

File tree

7 files changed

+56
-35
lines changed

7 files changed

+56
-35
lines changed

__tests__/esm/utilities.test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ describe('utilities', () => {
3333
});
3434

3535
it('exports "returnFirstArg" function', () => {
36-
assert.strictEqual(typeof returnFirstArg, 'function');
36+
assert.strictEqual(returnFirstArg('arg'), 'arg');
3737
});
3838
});

__tests__/utilities.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ELEMENTS_WITH_NO_TEXT_CHILDREN,
88
isCustomComponent,
99
PRESERVE_CUSTOM_ATTRIBUTES,
10+
returnFirstArg,
1011
setStyleProp,
1112
} from '../src/utilities';
1213

@@ -98,3 +99,9 @@ describe('canTextBeChildOfNode', () => {
9899
expect(canTextBeChildOfNode(node)).toBe(true);
99100
});
100101
});
102+
103+
describe('returnFirstArg', () => {
104+
it('returns first argument', () => {
105+
expect(returnFirstArg('arg')).toBe('arg');
106+
});
107+
});

eslint.config.mjs

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,39 @@
1-
import path from 'node:path';
21
import { fileURLToPath } from 'node:url';
32

43
import { includeIgnoreFile } from '@eslint/compat';
5-
import { FlatCompat } from '@eslint/eslintrc';
6-
import js from '@eslint/js';
7-
import typescriptEslint from '@typescript-eslint/eslint-plugin';
8-
import tsParser from '@typescript-eslint/parser';
4+
import eslint from '@eslint/js';
5+
import { defineConfig } from 'eslint/config';
96
import prettier from 'eslint-plugin-prettier';
107
import simpleImportSort from 'eslint-plugin-simple-import-sort';
118
import globals from 'globals';
9+
import tseslint from 'typescript-eslint';
1210

13-
const __filename = fileURLToPath(import.meta.url);
14-
const __dirname = path.dirname(__filename);
15-
const gitignorePath = path.resolve(__dirname, '.gitignore');
11+
const gitignorePath = fileURLToPath(new URL('.gitignore', import.meta.url));
1612

17-
const compat = new FlatCompat({
18-
baseDirectory: __dirname,
19-
recommendedConfig: js.configs.recommended,
20-
allConfig: js.configs.all,
21-
});
22-
23-
export default [
13+
export default defineConfig([
2414
includeIgnoreFile(gitignorePath),
2515

26-
...compat.extends(
27-
'eslint:recommended',
28-
'plugin:@typescript-eslint/recommended',
29-
),
16+
{
17+
ignores: ['examples/*'],
18+
},
3019

3120
{
32-
files: ['**/*.js', '**/*.mjs', '**/*.ts', '**/*.tsx'],
21+
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}'],
3322

3423
plugins: {
35-
'@typescript-eslint': typescriptEslint,
3624
'simple-import-sort': simpleImportSort,
25+
eslint,
3726
prettier,
3827
},
3928

29+
extends: ['eslint/recommended'],
30+
4031
languageOptions: {
4132
globals: {
4233
...globals.browser,
4334
...globals.jest,
4435
...globals.node,
4536
},
46-
parser: tsParser,
4737
},
4838

4939
rules: {
@@ -57,15 +47,13 @@ export default [
5747
},
5848
},
5949

50+
tseslint.configs.recommended,
51+
6052
{
6153
files: ['__tests__/**'],
6254

6355
rules: {
6456
'@typescript-eslint/no-require-imports': 'off',
6557
},
6658
},
67-
68-
{
69-
ignores: ['examples/*'],
70-
},
71-
];
59+
]);

package-lock.json

Lines changed: 25 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@
6969
"@types/node": "22.15.30",
7070
"@types/react": "19.1.6",
7171
"@types/react-dom": "19.1.6",
72-
"@typescript-eslint/eslint-plugin": "8.33.1",
73-
"@typescript-eslint/parser": "8.33.1",
7472
"benchmark": "2.1.4",
7573
"eslint": "9.28.0",
7674
"eslint-plugin-prettier": "5.4.1",
@@ -88,7 +86,8 @@
8886
"size-limit": "11.2.0",
8987
"ts-jest": "29.3.4",
9088
"ts-node": "10.9.2",
91-
"typescript": "5.8.3"
89+
"typescript": "5.8.3",
90+
"typescript-eslint": "8.33.1"
9291
},
9392
"peerDependencies": {
9493
"@types/react": "0.14 || 15 || 16 || 17 || 18 || 19",

src/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,23 @@ export interface HTMLReactParserOptions {
77
htmlparser2?: ParserOptions & DomHandlerOptions;
88

99
library?: {
10+
/* eslint-disable @typescript-eslint/no-explicit-any */
1011
cloneElement: (
1112
element: JSX.Element,
1213
props?: object,
1314
...children: any[]
1415
) => JSX.Element;
16+
1517
createElement: (
1618
type: any,
1719
props?: object,
1820
...children: any[]
1921
) => JSX.Element;
22+
2023
isValidElement: (element: any) => boolean;
24+
2125
[key: string]: any;
26+
/* eslint-enable @typescript-eslint/no-explicit-any */
2227
};
2328

2429
replace?: (

src/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ export const canTextBeChildOfNode = (node: Element) =>
112112
* @param arg - The argument to be returned.
113113
* @returns - The input argument `arg`.
114114
*/
115-
export const returnFirstArg = (arg: any) => arg;
115+
export const returnFirstArg = (arg: any) => arg; // eslint-disable-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)