Skip to content

Commit

Permalink
chore: add linting (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
piecyk authored Feb 8, 2022
1 parent 6c34bf4 commit 9412e44
Show file tree
Hide file tree
Showing 5 changed files with 497 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
build
23 changes: 16 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
"private": true,
"repository": "https://github.com/tanstack/react-virtual.git",
"scripts": {
"build": "yarn lint && rollup --config rollup.config.js && tsc -b",
"cipublish": "ts-node scripts/publish.ts",
"cipublishforce": "YARN_REGISTRY=https://registry.npmjs.org CI=true yarn cipublish",
"dev": "yarn watch",
"linkAll": "lerna exec 'yarn link'",
"unlinkAll": "lerna exec 'yarn unlink'",
"lint": "eslint ./packages --ext .js,.ts,.tsx",
"prettier": "prettier \"packages/*/{src/**,examples/**/src/**}.{md,js,jsx,ts,tsx,json}\" --write",
"test": "(is-ci && yarn test:ci) || yarn test:dev",
"test:ci": "jest",
"test:dev": "jest --watch",
"build": "rollup --config rollup.config.js && tsc -b",
"watch": "concurrently --kill-others \"rollup --config rollup.config.js -w\" \"tsc -b --watch\"",
"dev": "yarn watch",
"prettier": "prettier \"packages/*/{src/**,examples/**/src/**}.{md,js,jsx,ts,tsx,json}\" --write",
"unlinkAll": "lerna exec 'yarn unlink'",
"visualize": "lerna exec 'open build/stats-html.html'",
"cipublish": "ts-node scripts/publish.ts",
"cipublishforce": "YARN_REGISTRY=https://registry.npmjs.org CI=true yarn cipublish"
"watch": "concurrently --kill-others \"rollup --config rollup.config.js -w\" \"tsc -b --watch\""
},
"workspaces": [
"./packages/react-virtual"
Expand All @@ -29,16 +30,24 @@
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-replace": "^3.0.1",
"@testing-library/dom": "^8.11.3",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "14.0.0-beta.10",
"@types/luxon": "^2.0.9",
"@types/node": "^17.0.12",
"@types/react": "^17.0.38",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"axios": "^0.25.0",
"babel-plugin-transform-async-to-promises": "^0.8.18",
"concurrently": "^7.0.0",
"current-git-branch": "^1.1.0",
"eslint": "^8.8.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^26.1.0",
"eslint-plugin-react-hooks": "^4.3.0",
"git-log-parser": "^1.2.0",
"jest": "^27.4.7",
"lerna": "^4.0.0",
Expand Down
22 changes: 22 additions & 0 deletions packages/react-virtual/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,27 @@
},
"devDependencies": {
"babel-plugin-transform-async-to-promises": "^0.8.18"
},
"eslintConfig": {
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"jest"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:react-hooks/recommended",
"plugin:jest/recommended"
],
"rules": {
"react-hooks/exhaustive-deps": [
"warn",
{
"additionalHooks": "(useIsomorphicLayoutEffect)"
}
]
}
}
}
10 changes: 5 additions & 5 deletions packages/react-virtual/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ interface ScrollToOptions {
align: ScrollAlignment
}

interface ScrollToOffsetOptions extends ScrollToOptions {}
type ScrollToOffsetOptions = ScrollToOptions

interface ScrollToIndexOptions extends ScrollToOptions {}
type ScrollToIndexOptions = ScrollToOptions

export interface Range {
start: number
Expand Down Expand Up @@ -358,8 +358,8 @@ const findNearestBinarySearch = (
value: number,
) => {
while (low <= high) {
let middle = ((low + high) / 2) | 0
let currentValue = getCurrentValue(middle)
const middle = ((low + high) / 2) | 0
const currentValue = getCurrentValue(middle)

if (currentValue < value) {
low = middle + 1
Expand Down Expand Up @@ -389,7 +389,7 @@ function calculateRange({
const size = measurements.length - 1
const getOffset = (index: number) => measurements[index].start

let start = findNearestBinarySearch(0, size, getOffset, scrollOffset)
const start = findNearestBinarySearch(0, size, getOffset, scrollOffset)
let end = start

while (end < size && measurements[end].end < scrollOffset + outerSize) {
Expand Down
Loading

0 comments on commit 9412e44

Please sign in to comment.