Skip to content

Commit

Permalink
chore: Add knip and sherif (#5357)
Browse files Browse the repository at this point in the history
* Add knip and sherif

* Update Nx command
  • Loading branch information
lachlancollins authored Feb 17, 2024
1 parent 0004886 commit 06f560c
Show file tree
Hide file tree
Showing 12 changed files with 1,024 additions and 70 deletions.
1 change: 0 additions & 1 deletion babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module.exports = {
'@babel/preset-typescript',
],
plugins: [
// 'babel-plugin-transform-async-to-promises',
cjs && ['@babel/transform-modules-commonjs', { loose }],
// [
// '@babel/transform-runtime',
Expand Down
12 changes: 12 additions & 0 deletions knip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://unpkg.com/knip@4/schema.json",
"ignoreWorkspaces": ["examples/**"],
"workspaces": {
"packages/match-sorter-utils": {
"ignoreDependencies": ["remove-accents"]
},
"packages/react-table": {
"ignore": ["**/*.notest.*", "**/makeTestData.ts"]
}
}
}
8 changes: 8 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,17 @@
"outputs": ["{projectRoot}/build", "{projectRoot}/dist"],
"cache": true
},
"test:knip": {
"cache": true,
"inputs": ["{workspaceRoot}/**/*"]
},
"test:format": {
"cache": true,
"inputs": ["{workspaceRoot}/**/*"]
},
"test:sherif": {
"cache": true,
"inputs": ["{workspaceRoot}/**/*"]
}
}
}
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
"clean": "pnpm --filter \"./packages/**\" run clean",
"preinstall": "node -e \"if(process.env.CI == 'true') {console.log('Skipping preinstall...'); process.exit(1)}\" || npx -y only-allow pnpm",
"test": "pnpm run test:ci",
"test:pr": "nx affected --targets=test:format,test:lib,test:types,build",
"test:ci": "nx run-many --targets=test:format,test:lib,test:types,build",
"test:pr": "nx affected --targets=test:format,test:sherif,test:knip,test:lib,test:types,build",
"test:ci": "nx run-many --targets=test:format,test:sherif,test:knip,test:lib,test:types,build",
"test:format": "pnpm run prettier --check",
"test:sherif": "sherif",
"test:lib": "nx affected --targets=test:lib --exclude=examples/**",
"test:lib:dev": "pnpm test:lib && nx watch --all -- pnpm test:lib",
"test:types": "nx affected --targets=test:types --exclude=examples/**",
"test:knip": "knip",
"build": "nx affected --targets=build --exclude=examples/**",
"build:all": "nx run-many --targets=build --exclude=examples/**",
"watch": "pnpm run build:all && nx watch --all -- pnpm run build:all",
Expand All @@ -24,7 +26,9 @@
},
"nx": {
"includedScripts": [
"test:format"
"test:format",
"test:knip",
"test:sherif"
]
},
"namespace": "@tanstack",
Expand All @@ -43,12 +47,11 @@
"@testing-library/jest-dom": "^6.2.0",
"@testing-library/react": "^14.1.2",
"@testing-library/react-hooks": "^8.0.1",
"@tsconfig/svelte": "^5.0.2",
"@types/node": "^18.19.4",
"@types/react": "^18.2.45",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"babel-plugin-transform-async-to-promises": "^0.8.18",
"jsdom": "^23.2.0",
"knip": "^4.6.0",
"nx": "^17.2.8",
"prettier": "^4.0.0-alpha.8",
"prettier-plugin-svelte": "^3.1.2",
Expand All @@ -59,11 +62,9 @@
"rollup-plugin-size": "^0.3.1",
"rollup-plugin-svelte": "^7.1.6",
"rollup-plugin-visualizer": "^5.12.0",
"solid-js": "^1.8.11",
"sherif": "^0.7.0",
"svelte": "^4.2.8",
"typescript": "5.3.3",
"vite": "^5.0.11",
"vitest": "^1.2.0",
"vue": "^3.4.14"
"vitest": "^1.2.0"
}
}
12 changes: 6 additions & 6 deletions packages/react-table-devtools/src/Explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ import React from 'react'

import { styled } from './utils'

export const Entry = styled('div', {
const Entry = styled('div', {
fontFamily: 'Menlo, monospace',
fontSize: '0.7rem',
lineHeight: '1.7',
outline: 'none',
wordBreak: 'break-word',
})

export const Label = styled('span', {
const Label = styled('span', {
cursor: 'pointer',
color: 'white',
})

export const Value = styled('span', (props, theme) => ({
const Value = styled('span', (props, theme) => ({
color: theme.danger,
}))

export const SubEntries = styled('div', {
const SubEntries = styled('div', {
marginLeft: '.1rem',
paddingLeft: '1rem',
borderLeft: '2px solid rgba(0,0,0,.15)',
})

export const Info = styled('span', {
const Info = styled('span', {
color: 'grey',
fontSize: '.7rem',
})

export const Expander = ({ expanded, style = {}, ...rest }) => (
const Expander = ({ expanded, style = {}, ...rest }) => (
<span
style={{
display: 'inline-block',
Expand Down
8 changes: 4 additions & 4 deletions packages/react-table-devtools/src/styledComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Panel = styled(
}
)

export const ActivePanel = styled(
const ActivePanel = styled(
'div',
() => ({
flex: '1 1 500px',
Expand Down Expand Up @@ -63,11 +63,11 @@ export const Button = styled('button', (props, theme) => ({
// borderRadius: '.2em',
// })

export const Code = styled('code', {
const Code = styled('code', {
fontSize: '.9em',
})

export const Input = styled('input', (_props, theme) => ({
const Input = styled('input', (_props, theme) => ({
backgroundColor: theme.inputBackgroundColor,
border: 0,
borderRadius: '.2em',
Expand All @@ -77,7 +77,7 @@ export const Input = styled('input', (_props, theme) => ({
padding: '.3em .4em',
}))

export const Select = styled(
const Select = styled(
'select',
(_props, theme) => ({
display: `inline-block`,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-table-devtools/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import { Theme, useTheme } from './theme'
import useMediaQuery from './useMediaQuery'

export const isServer = typeof window === 'undefined'
const isServer = typeof window === 'undefined'

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

Expand Down
6 changes: 2 additions & 4 deletions packages/react-table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@
"@tanstack/table-core": "workspace:*"
},
"devDependencies": {
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.18",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"@types/react": "^18.2.48",
"react": "^18.2.0"
},
"peerDependencies": {
"react": ">=16",
Expand Down
4 changes: 2 additions & 2 deletions packages/table-core/src/utils/filterRowsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function filterRows<TData extends RowData>(
return filterRowModelFromRoot(rows, filterRowImpl, table)
}

export function filterRowModelFromLeafs<TData extends RowData>(
function filterRowModelFromLeafs<TData extends RowData>(
rowsToFilter: Row<TData>[],
filterRow: (row: Row<TData>) => Row<TData>[],
table: Table<TData>
Expand Down Expand Up @@ -77,7 +77,7 @@ export function filterRowModelFromLeafs<TData extends RowData>(
}
}

export function filterRowModelFromRoot<TData extends RowData>(
function filterRowModelFromRoot<TData extends RowData>(
rowsToFilter: Row<TData>[],
filterRow: (row: Row<TData>) => any,
table: Table<TData>
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-table/src/merge-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function trueFn() {
return true
}

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

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

0 comments on commit 06f560c

Please sign in to comment.