Skip to content

Commit a292059

Browse files
authored
Merge pull request #2995 from tanem/tooling
Modernise tooling configuration
2 parents 375ffd8 + 58b607d commit a292059

File tree

11 files changed

+95
-131
lines changed

11 files changed

+95
-131
lines changed

eslint.config.mjs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,37 @@
11
import path from 'node:path'
22
import { fileURLToPath } from 'node:url'
33

4-
import { fixupPluginRules } from '@eslint/compat'
5-
import { FlatCompat } from '@eslint/eslintrc'
64
import js from '@eslint/js'
7-
import typescriptEslint from '@typescript-eslint/eslint-plugin'
8-
import tsParser from '@typescript-eslint/parser'
5+
import eslintConfigPrettier from 'eslint-config-prettier'
96
import react from 'eslint-plugin-react'
107
import reactHooks from 'eslint-plugin-react-hooks'
118
import simpleImportSort from 'eslint-plugin-simple-import-sort'
9+
import globals from 'globals'
10+
import tseslint from 'typescript-eslint'
1211

1312
const __filename = fileURLToPath(import.meta.url)
1413
const __dirname = path.dirname(__filename)
15-
const compat = new FlatCompat({
16-
allConfig: js.configs.all,
17-
baseDirectory: __dirname,
18-
recommendedConfig: js.configs.recommended,
19-
})
2014

21-
export default [
15+
export default tseslint.config(
2216
{
2317
ignores: ['**/compiled/', '**/coverage/', '**/dist/', '**/node_modules/'],
2418
},
25-
...compat.extends(
26-
'plugin:react/recommended',
27-
'plugin:@typescript-eslint/recommended',
28-
'prettier',
29-
),
19+
js.configs.recommended,
20+
...tseslint.configs.recommended,
21+
react.configs.flat.recommended,
22+
eslintConfigPrettier,
3023
{
3124
languageOptions: {
32-
ecmaVersion: 5,
33-
parser: tsParser,
3425
parserOptions: {
3526
ecmaFeatures: {
3627
jsx: true,
3728
},
3829
project: path.join(__dirname, 'tsconfig.eslint.json'),
3930
},
40-
sourceType: 'module',
4131
},
4232

4333
plugins: {
44-
'@typescript-eslint': typescriptEslint,
45-
react,
46-
'react-hooks': fixupPluginRules(reactHooks),
34+
'react-hooks': reactHooks,
4735
'simple-import-sort': simpleImportSort,
4836
},
4937

@@ -67,11 +55,24 @@ export default [
6755
},
6856
{
6957
files: ['**/*.js'],
58+
languageOptions: {
59+
globals: {
60+
...globals.node,
61+
},
62+
},
7063
rules: {
7164
'@typescript-eslint/explicit-module-boundary-types': 'off',
7265
'@typescript-eslint/no-require-imports': 'off',
7366
},
7467
},
68+
{
69+
files: ['examples/plain-js/**/*.js'],
70+
languageOptions: {
71+
globals: {
72+
...globals.browser,
73+
},
74+
},
75+
},
7576
{
7677
files: ['examples/**/*'],
7778
rules: {
@@ -85,4 +86,4 @@ export default [
8586
'react/prop-types': 'off',
8687
},
8788
},
88-
]
89+
)

package-lock.json

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

package.json

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"description": "A React primitive for building slim progress bars.",
55
"main": "dist/index.js",
66
"module": "dist/react-nprogress.esm.js",
7-
"jsnext:main": "dist/react-nprogress.esm.js",
8-
"typings": "dist/index.d.ts",
7+
"types": "dist/index.d.ts",
98
"sideEffects": false,
109
"files": [
1110
"dist"
@@ -71,13 +70,11 @@
7170
"hoist-non-react-statics": "^3.3.2"
7271
},
7372
"devDependencies": {
74-
"@babel/core": "7.29.0",
75-
"@babel/plugin-transform-runtime": "7.29.0",
76-
"@babel/preset-env": "7.29.0",
73+
"@babel/core": "^7.29.0",
74+
"@babel/plugin-transform-runtime": "^7.29.0",
75+
"@babel/preset-env": "^7.29.0",
7776
"@babel/preset-react": "7.28.5",
7877
"@babel/preset-typescript": "7.28.5",
79-
"@eslint/compat": "2.0.2",
80-
"@eslint/eslintrc": "3.3.3",
8178
"@eslint/js": "9.39.2",
8279
"@rollup/plugin-babel": "6.1.0",
8380
"@rollup/plugin-commonjs": "29.0.0",
@@ -91,26 +88,24 @@
9188
"@types/node": "24.10.13",
9289
"@types/react": "19.2.14",
9390
"@types/react-dom": "19.2.3",
94-
"@typescript-eslint/eslint-plugin": "8.55.0",
95-
"@typescript-eslint/parser": "8.55.0",
9691
"eslint": "9.39.2",
9792
"eslint-config-prettier": "10.1.8",
9893
"eslint-plugin-react": "7.37.5",
9994
"eslint-plugin-react-hooks": "7.0.1",
10095
"eslint-plugin-simple-import-sort": "12.1.1",
96+
"globals": "^17.3.0",
10197
"jest": "30.2.0",
10298
"jest-environment-jsdom": "30.2.0",
10399
"mock-raf": "1.0.1",
104100
"npm-run-all2": "8.0.4",
105101
"prettier": "3.8.1",
106102
"react": "19.2.4",
107103
"react-dom": "19.2.4",
108-
"react-test-renderer": "19.2.4",
109-
"regenerator-runtime": "0.14.1",
110104
"rollup": "4.57.1",
111105
"shx": "0.4.0",
112106
"tanem-scripts": "8.0.2",
113107
"ts-jest": "29.4.6",
114-
"typescript": "5.9.3"
108+
"typescript": "5.9.3",
109+
"typescript-eslint": "^8.55.0"
115110
}
116111
}

rollup.config.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ const getBabelConfig = () => ({
4747
exclude: 'node_modules/**',
4848
inputSourceMap: true,
4949
plugins: ['@babel/transform-runtime'],
50-
presets: [['@babel/env', { loose: true, modules: false }], '@babel/react'],
50+
presets: [
51+
['@babel/env', { modules: false }],
52+
['@babel/react', { runtime: 'automatic' }],
53+
],
5154
})
5255

5356
const getPlugins = (bundleType) => [
@@ -68,10 +71,7 @@ const getPlugins = (bundleType) => [
6871
keep_infinity: true,
6972
pure_getters: true,
7073
},
71-
ecma: 5,
7274
output: { comments: false },
73-
toplevel: false,
74-
warnings: true,
7575
}),
7676
]
7777

@@ -113,6 +113,7 @@ const getUmdConfig = (bundleType) => ({
113113
globals: {
114114
react: 'React',
115115
'react-dom': 'ReactDOM',
116+
'react/jsx-runtime': 'React',
116117
},
117118
name: 'NProgress',
118119
sourcemap: true,

src/NProgress.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import * as React from 'react'
1+
import type { FC, ReactElement } from 'react'
22

3-
import { Options } from './types'
3+
import type { Options } from './types'
44
import { useNProgress } from './useNProgress'
55

66
type Props = Options & {
7-
children: (renderProps: ReturnType<typeof useNProgress>) => React.ReactElement
7+
children: (renderProps: ReturnType<typeof useNProgress>) => ReactElement
88
}
99

10-
export const NProgress: React.FC<Props> = ({
11-
children,
12-
...restProps
13-
}: Props) => {
10+
export const NProgress: FC<Props> = ({ children, ...restProps }: Props) => {
1411
const renderProps = useNProgress(restProps)
1512
return children(renderProps)
1613
}

src/env.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
declare module 'react-lifecycles-compat'

0 commit comments

Comments
 (0)