Skip to content

Enable noPropertyAccessFromIndexSignature and noUncheckedIndexedAccess #216

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

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Changes from 1 commit
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
Next Next commit
Enable noPropertyAccessFromIndexSignature and noUncheckedIndexedAccess
  • Loading branch information
sporto committed Nov 14, 2024

Verified

This commit was signed with the committer’s verified signature.
sporto Sebastian Porto
commit 21657d0f0a91fccd81135c06941c94e6d6574982
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@
"scripts": {
"lint": "eslint . --ext .ts,.js",
"test": "jest",
"build": "node tools/build.js"
"build": "node tools/build.js",
"tsc": "tsc --noEmit"
}
}
2 changes: 1 addition & 1 deletion src/UniversalRouter.test.ts
Original file line number Diff line number Diff line change
@@ -514,7 +514,7 @@ test('respects baseUrl', async () => {
expect(action.mock.calls[0][0]).toHaveProperty('pathname', '/base/a/b/c')
expect(action.mock.calls[0][0]).toHaveProperty('path', '/c')
expect(action.mock.calls[0][0]).toHaveProperty('baseUrl', '/base/a/b')
expect(action.mock.calls[0][0]).toHaveProperty('route', routes.children[0].children[0])
expect(action.mock.calls[0][0]).toHaveProperty('route', routes.children[0]?.children[0])
expect(action.mock.calls[0][0]).toHaveProperty('router', router)

let err
4 changes: 2 additions & 2 deletions src/UniversalRouter.ts
Original file line number Diff line number Diff line change
@@ -190,7 +190,7 @@
if (matchResult && route.children) {
while (childIndex < route.children.length) {
if (!childMatches) {
const childRoute = route.children[childIndex]
const childRoute = route.children[childIndex]!

Check warning on line 193 in src/UniversalRouter.ts

GitHub Actions / build (14.x)

Forbidden non-null assertion
childRoute.parent = route

childMatches = matchRoute<R, C>(
@@ -320,7 +320,7 @@
})
}

context.next = next
context['next'] = next

Check failure on line 323 in src/UniversalRouter.ts

GitHub Actions / build (14.x)

["next"] is better written in dot notation

return Promise.resolve()
.then(() => next(true, this.root))
2 changes: 1 addition & 1 deletion src/UniversalRouterSync.test.ts
Original file line number Diff line number Diff line change
@@ -511,7 +511,7 @@ test('respects baseUrl', () => {
expect(action.mock.calls[0][0]).toHaveProperty('pathname', '/base/a/b/c')
expect(action.mock.calls[0][0]).toHaveProperty('path', '/c')
expect(action.mock.calls[0][0]).toHaveProperty('baseUrl', '/base/a/b')
expect(action.mock.calls[0][0]).toHaveProperty('route', routes.children[0].children[0])
expect(action.mock.calls[0][0]).toHaveProperty('route', routes.children[0]?.children[0])
expect(action.mock.calls[0][0]).toHaveProperty('router', router)

let err
4 changes: 2 additions & 2 deletions src/UniversalRouterSync.ts
Original file line number Diff line number Diff line change
@@ -191,7 +191,7 @@
if (matchResult && route.children) {
while (childIndex < route.children.length) {
if (!childMatches) {
const childRoute = route.children[childIndex]
const childRoute = route.children[childIndex]!

Check warning on line 194 in src/UniversalRouterSync.ts

GitHub Actions / build (14.x)

Forbidden non-null assertion
childRoute.parent = route

childMatches = matchRoute<R, C>(
@@ -318,7 +318,7 @@
return next(resume, parent, result)
}

context.next = next
context['next'] = next

Check failure on line 321 in src/UniversalRouterSync.ts

GitHub Actions / build (14.x)

["next"] is better written in dot notation

try {
return next(true, this.root)
8 changes: 4 additions & 4 deletions src/generateUrls.ts
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@

if (routes) {
for (let i = 0; i < routes.length; i++) {
const childRoute = routes[i]
const childRoute = routes[i]!

Check warning on line 60 in src/generateUrls.ts

GitHub Actions / build (14.x)

Forbidden non-null assertion
const childName = childRoute.name
childRoute.parent = route
cacheRoutes(
@@ -117,7 +117,7 @@
const keys: Keys = Object.create(null)
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i]
if (typeof token !== 'string') {
if (token && typeof token !== 'string') {
keys[token.name] = true
}
}
@@ -132,8 +132,8 @@
const keys = Object.keys(params)
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
if (!regexp.keys[key]) {
queryParams[key] = params[key]
if (key && !regexp.keys[key]) {
queryParams[key] = params[key] ?? ''
}
}
const query = opts.stringifyQueryParams(queryParams)
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@
"strict": true,
"declaration": true,
"noEmitOnError": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"sourceMap": true,