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

chore: Setup eslint for packages/nuqs #582

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"scripts": {
"dev": "turbo run dev",
"lint": "turbo run lint",
"build": "turbo run build",
"test": "turbo run test",
"prepare": "husky"
Expand Down
39 changes: 39 additions & 0 deletions packages/nuqs/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import globals from 'globals'
import pluginJs from '@eslint/js'
import tseslint from 'typescript-eslint'
import pluginReactConfig from 'eslint-plugin-react/configs/recommended.js'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import pluginReactCompiler from 'eslint-plugin-react-compiler'

/** @type {Awaited<import('typescript-eslint').Config>} */
export default [
{ files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] },
{ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } },
{ languageOptions: { globals: { ...globals.browser, ...globals.node } } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReactConfig,
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'no-useless-escape': 'off'
}
},
{
settings: {
react: {
version: 'detect'
}
},
plugins: {
'react-hooks': pluginReactHooks,
'react-compiler': pluginReactCompiler
},
rules: {
...pluginReactHooks.configs.recommended.rules,
'react-compiler/react-compiler': 'error'
}
},
{ ignores: ['**/*.test-d.ts'] }
]
10 changes: 9 additions & 1 deletion packages/nuqs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"test:types": "tsd",
"test:unit": "vitest run",
"test:size": "size-limit",
"prepack": "./scripts/prepack.sh"
"prepack": "./scripts/prepack.sh",
"lint": "eslint src"
},
"peerDependencies": {
"next": ">=13.4 <14.0.2 || ^14.0.3"
Expand All @@ -70,10 +71,16 @@
"mitt": "^3.0.1"
},
"devDependencies": {
"@eslint/js": "^9.5.0",
"@size-limit/preset-small-lib": "^11.1.2",
"@types/node": "^20.12.8",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"eslint": "8.x",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-compiler": "0.0.0-experimental-0998c1e-20240625",
"eslint-plugin-react-hooks": "^4.6.2",
"globals": "^15.6.0",
"next": "^14.2.3",
"npm-run-all": "^4.1.5",
"react": "rc",
Expand All @@ -82,6 +89,7 @@
"tsd": "^0.30.7",
"tsup": "^8.0.2",
"typescript": "^5.4.5",
"typescript-eslint": "^7.14.1",
"vitest": "^1.6.0"
},
"tsd": {
Expand Down
2 changes: 1 addition & 1 deletion packages/nuqs/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRouter } from 'next/navigation.js' // https://github.com/47ng/nuqs/discussions/352
import type { useRouter } from 'next/navigation.js' // https://github.com/47ng/nuqs/discussions/352
import type { TransitionStartFunction } from 'react'

export type Router = ReturnType<typeof useRouter>
Expand Down
1 change: 1 addition & 0 deletions packages/nuqs/src/useQueryStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export function useQueryStates<KeyMap extends UseQueryStatesKeysMap>(
? stateUpdater(stateRef.current)
: stateUpdater
debug('[nuq+ `%s`] setState: %O', keys, newState)
// eslint-disable-next-line prefer-const
for (let [key, value] of Object.entries(newState)) {
const config = keyMap[key]
if (!config) {
Expand Down
Loading