Skip to content

Commit 06f560c

Browse files
authoredFeb 17, 2024··
chore: Add knip and sherif (#5357)
* Add knip and sherif * Update Nx command
1 parent 0004886 commit 06f560c

File tree

12 files changed

+1024
-70
lines changed

12 files changed

+1024
-70
lines changed
 

‎babel.config.cjs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ module.exports = {
2121
'@babel/preset-typescript',
2222
],
2323
plugins: [
24-
// 'babel-plugin-transform-async-to-promises',
2524
cjs && ['@babel/transform-modules-commonjs', { loose }],
2625
// [
2726
// '@babel/transform-runtime',

‎knip.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://unpkg.com/knip@4/schema.json",
3+
"ignoreWorkspaces": ["examples/**"],
4+
"workspaces": {
5+
"packages/match-sorter-utils": {
6+
"ignoreDependencies": ["remove-accents"]
7+
},
8+
"packages/react-table": {
9+
"ignore": ["**/*.notest.*", "**/makeTestData.ts"]
10+
}
11+
}
12+
}

‎nx.json

+8
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,17 @@
4444
"outputs": ["{projectRoot}/build", "{projectRoot}/dist"],
4545
"cache": true
4646
},
47+
"test:knip": {
48+
"cache": true,
49+
"inputs": ["{workspaceRoot}/**/*"]
50+
},
4751
"test:format": {
4852
"cache": true,
4953
"inputs": ["{workspaceRoot}/**/*"]
54+
},
55+
"test:sherif": {
56+
"cache": true,
57+
"inputs": ["{workspaceRoot}/**/*"]
5058
}
5159
}
5260
}

‎package.json

+11-10
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
"clean": "pnpm --filter \"./packages/**\" run clean",
99
"preinstall": "node -e \"if(process.env.CI == 'true') {console.log('Skipping preinstall...'); process.exit(1)}\" || npx -y only-allow pnpm",
1010
"test": "pnpm run test:ci",
11-
"test:pr": "nx affected --targets=test:format,test:lib,test:types,build",
12-
"test:ci": "nx run-many --targets=test:format,test:lib,test:types,build",
11+
"test:pr": "nx affected --targets=test:format,test:sherif,test:knip,test:lib,test:types,build",
12+
"test:ci": "nx run-many --targets=test:format,test:sherif,test:knip,test:lib,test:types,build",
1313
"test:format": "pnpm run prettier --check",
14+
"test:sherif": "sherif",
1415
"test:lib": "nx affected --targets=test:lib --exclude=examples/**",
1516
"test:lib:dev": "pnpm test:lib && nx watch --all -- pnpm test:lib",
1617
"test:types": "nx affected --targets=test:types --exclude=examples/**",
18+
"test:knip": "knip",
1719
"build": "nx affected --targets=build --exclude=examples/**",
1820
"build:all": "nx run-many --targets=build --exclude=examples/**",
1921
"watch": "pnpm run build:all && nx watch --all -- pnpm run build:all",
@@ -24,7 +26,9 @@
2426
},
2527
"nx": {
2628
"includedScripts": [
27-
"test:format"
29+
"test:format",
30+
"test:knip",
31+
"test:sherif"
2832
]
2933
},
3034
"namespace": "@tanstack",
@@ -43,12 +47,11 @@
4347
"@testing-library/jest-dom": "^6.2.0",
4448
"@testing-library/react": "^14.1.2",
4549
"@testing-library/react-hooks": "^8.0.1",
46-
"@tsconfig/svelte": "^5.0.2",
4750
"@types/node": "^18.19.4",
48-
"@types/react": "^18.2.45",
51+
"@types/react": "^18.2.48",
4952
"@types/react-dom": "^18.2.18",
50-
"babel-plugin-transform-async-to-promises": "^0.8.18",
5153
"jsdom": "^23.2.0",
54+
"knip": "^4.6.0",
5255
"nx": "^17.2.8",
5356
"prettier": "^4.0.0-alpha.8",
5457
"prettier-plugin-svelte": "^3.1.2",
@@ -59,11 +62,9 @@
5962
"rollup-plugin-size": "^0.3.1",
6063
"rollup-plugin-svelte": "^7.1.6",
6164
"rollup-plugin-visualizer": "^5.12.0",
62-
"solid-js": "^1.8.11",
65+
"sherif": "^0.7.0",
6366
"svelte": "^4.2.8",
6467
"typescript": "5.3.3",
65-
"vite": "^5.0.11",
66-
"vitest": "^1.2.0",
67-
"vue": "^3.4.14"
68+
"vitest": "^1.2.0"
6869
}
6970
}

‎packages/react-table-devtools/src/Explorer.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,35 @@ import React from 'react'
44

55
import { styled } from './utils'
66

7-
export const Entry = styled('div', {
7+
const Entry = styled('div', {
88
fontFamily: 'Menlo, monospace',
99
fontSize: '0.7rem',
1010
lineHeight: '1.7',
1111
outline: 'none',
1212
wordBreak: 'break-word',
1313
})
1414

15-
export const Label = styled('span', {
15+
const Label = styled('span', {
1616
cursor: 'pointer',
1717
color: 'white',
1818
})
1919

20-
export const Value = styled('span', (props, theme) => ({
20+
const Value = styled('span', (props, theme) => ({
2121
color: theme.danger,
2222
}))
2323

24-
export const SubEntries = styled('div', {
24+
const SubEntries = styled('div', {
2525
marginLeft: '.1rem',
2626
paddingLeft: '1rem',
2727
borderLeft: '2px solid rgba(0,0,0,.15)',
2828
})
2929

30-
export const Info = styled('span', {
30+
const Info = styled('span', {
3131
color: 'grey',
3232
fontSize: '.7rem',
3333
})
3434

35-
export const Expander = ({ expanded, style = {}, ...rest }) => (
35+
const Expander = ({ expanded, style = {}, ...rest }) => (
3636
<span
3737
style={{
3838
display: 'inline-block',

‎packages/react-table-devtools/src/styledComponents.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const Panel = styled(
2020
}
2121
)
2222

23-
export const ActivePanel = styled(
23+
const ActivePanel = styled(
2424
'div',
2525
() => ({
2626
flex: '1 1 500px',
@@ -63,11 +63,11 @@ export const Button = styled('button', (props, theme) => ({
6363
// borderRadius: '.2em',
6464
// })
6565

66-
export const Code = styled('code', {
66+
const Code = styled('code', {
6767
fontSize: '.9em',
6868
})
6969

70-
export const Input = styled('input', (_props, theme) => ({
70+
const Input = styled('input', (_props, theme) => ({
7171
backgroundColor: theme.inputBackgroundColor,
7272
border: 0,
7373
borderRadius: '.2em',
@@ -77,7 +77,7 @@ export const Input = styled('input', (_props, theme) => ({
7777
padding: '.3em .4em',
7878
}))
7979

80-
export const Select = styled(
80+
const Select = styled(
8181
'select',
8282
(_props, theme) => ({
8383
display: `inline-block`,

‎packages/react-table-devtools/src/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react'
33
import { Theme, useTheme } from './theme'
44
import useMediaQuery from './useMediaQuery'
55

6-
export const isServer = typeof window === 'undefined'
6+
const isServer = typeof window === 'undefined'
77

88
type StyledComponent<T> = T extends 'button'
99
? React.DetailedHTMLProps<
@@ -104,7 +104,7 @@ export function useIsMounted() {
104104
* to prevent updating a component state while React is rendering different components
105105
* or when the component is not mounted anymore.
106106
*/
107-
export function useSafeState<T>(initialState: T): [T, (value: T) => void] {
107+
function useSafeState<T>(initialState: T): [T, (value: T) => void] {
108108
const isMounted = useIsMounted()
109109
const [state, setState] = React.useState(initialState)
110110

‎packages/react-table/package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@
5454
"@tanstack/table-core": "workspace:*"
5555
},
5656
"devDependencies": {
57-
"@types/react": "^18.2.45",
58-
"@types/react-dom": "^18.2.18",
59-
"react": "^18.2.0",
60-
"react-dom": "^18.2.0"
57+
"@types/react": "^18.2.48",
58+
"react": "^18.2.0"
6159
},
6260
"peerDependencies": {
6361
"react": ">=16",

‎packages/table-core/src/utils/filterRowsUtils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function filterRows<TData extends RowData>(
1313
return filterRowModelFromRoot(rows, filterRowImpl, table)
1414
}
1515

16-
export function filterRowModelFromLeafs<TData extends RowData>(
16+
function filterRowModelFromLeafs<TData extends RowData>(
1717
rowsToFilter: Row<TData>[],
1818
filterRow: (row: Row<TData>) => Row<TData>[],
1919
table: Table<TData>
@@ -77,7 +77,7 @@ export function filterRowModelFromLeafs<TData extends RowData>(
7777
}
7878
}
7979

80-
export function filterRowModelFromRoot<TData extends RowData>(
80+
function filterRowModelFromRoot<TData extends RowData>(
8181
rowsToFilter: Row<TData>[],
8282
filterRow: (row: Row<TData>) => any,
8383
table: Table<TData>

‎packages/vue-table/src/merge-proxy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function trueFn() {
22
return true
33
}
44

5-
export const $PROXY = Symbol('merge-proxy')
5+
const $PROXY = Symbol('merge-proxy')
66

77
// https://github.com/solidjs/solid/blob/c20ca4fd8c36bc0522fedb2c7f38a110b7ee2663/packages/solid/src/render/component.ts#L51-L118
88
const propTraps: ProxyHandler<{

‎pnpm-lock.yaml

+970-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎scripts/getRollupConfig.js

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { resolve } from 'node:path'
44
import { babel } from '@rollup/plugin-babel'
5+
import commonJS from '@rollup/plugin-commonjs'
56
import { visualizer } from 'rollup-plugin-visualizer'
67
import terser from '@rollup/plugin-terser'
78
// @ts-expect-error
@@ -89,6 +90,7 @@ function mjs({ input, external, banner, outputFile }) {
8990
hydratable: true,
9091
},
9192
}),
93+
commonJS(),
9294
babelPlugin,
9395
nodeResolve({ extensions: ['.ts', '.tsx'] }),
9496
],
@@ -122,6 +124,7 @@ function esm({ input, external, banner, outputFile }) {
122124
hydratable: true,
123125
},
124126
}),
127+
commonJS(),
125128
babelPlugin,
126129
nodeResolve({ extensions: ['.ts', '.tsx'] }),
127130
],
@@ -153,6 +156,7 @@ function cjs({ input, external, banner }) {
153156
},
154157
plugins: [
155158
svelte(),
159+
commonJS(),
156160
babelPlugin,
157161
nodeResolve({ extensions: ['.ts', '.tsx'] }),
158162
],
@@ -184,6 +188,7 @@ function umdDev({ input, external, globals, banner, jsName }) {
184188
},
185189
plugins: [
186190
svelte(),
191+
commonJS(),
187192
babelPlugin,
188193
nodeResolve({ extensions: ['.ts', '.tsx'] }),
189194
forceEnvPlugin('development'),
@@ -216,6 +221,7 @@ function umdProd({ input, external, globals, banner, jsName }) {
216221
},
217222
plugins: [
218223
svelte(),
224+
commonJS(),
219225
babelPlugin,
220226
nodeResolve({ extensions: ['.ts', '.tsx'] }),
221227
forceEnvPlugin('production'),

0 commit comments

Comments
 (0)
Please sign in to comment.