Skip to content

Commit

Permalink
fix: Defer the assignment of matchSorter.rankings (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
mochaaP authored Jan 16, 2024
1 parent c62eed1 commit 901882d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ jobs:
if: ${{ !contains(github.head_ref, 'all-contributors') }}
strategy:
matrix:
node: [10.13, 12, 14, 15]
node: [lts/-1, lts/*, latest]
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: ⎔ Setup node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

Expand All @@ -43,7 +43,7 @@ jobs:
run: npm run validate

- name: ⬆️ Upload coverage report
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3

release:
needs: main
Expand All @@ -54,12 +54,12 @@ jobs:
github.ref) && github.event_name == 'push' }}
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: ⎔ Setup node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 14
node-version: lts/*

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
Expand All @@ -72,9 +72,8 @@ jobs:
run: npm run build

- name: 🚀 Release
uses: cycjimmy/semantic-release-action@v2
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 17
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"author": "Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@babel/runtime": "^7.23.8",
"remove-accents": "0.5.0"
},
"devDependencies": {
"@types/jest": "^26.0.15",
"kcd-scripts": "^7.2.0",
"typescript": "^4.1.2"
"kcd-scripts": "^15",
"typescript": "^5.3"
},
"eslintConfig": {
"extends": [
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ for (const [

/*
eslint
jest/prefer-each: "off",
jest/valid-title: "off",
jest/no-disabled-tests: "off",
jest/no-focused-tests: "off",
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ const rankings = {

type Ranking = typeof rankings[keyof typeof rankings]

matchSorter.rankings = rankings

const defaultBaseSortFn: BaseSorter<unknown> = (a, b) =>
String(a.rankedValue).localeCompare(String(b.rankedValue))

Expand Down Expand Up @@ -110,6 +108,8 @@ function matchSorter<ItemType = string>(
}
}

matchSorter.rankings = rankings

/**
* Gets the highest ranking for value for the given item based on its values for the given keys
* @param {*} item - the item to rank
Expand Down Expand Up @@ -368,7 +368,7 @@ function getItemValues<ItemType>(
value = key(item)
} else if (item == null) {
value = null
} else if (Object.hasOwnProperty.call(item, key)) {
} else if (Object.hasOwn(item, key)) {
value = (item as IndexableByString)[key]
} else if (key.includes('.')) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
Expand Down Expand Up @@ -412,7 +412,7 @@ function getNestedValues<ItemType>(

if (nestedItem == null) continue

if (Object.hasOwnProperty.call(nestedItem, nestedKey)) {
if (Object.hasOwn(nestedItem as object, nestedKey)) {
const nestedValue = (nestedItem as IndexableByString)[nestedKey]
if (nestedValue != null) {
nestedValues.push(nestedValue as IndexableByString | string)
Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "./node_modules/kcd-scripts/shared-tsconfig.json"
"extends": "./node_modules/kcd-scripts/shared-tsconfig.json",
"compilerOptions": {
"lib": ["ESNext"]
}
}

0 comments on commit 901882d

Please sign in to comment.