style: require-array-sort-compare for non-strings
This commit is contained in:
2 files changed
+10
-5
No files matched your search
@@ -47,7 +47,6 @@
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/triple-slash-reference": "off",
|
||||
"@typescript-eslint/require-array-sort-compare": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/consistent-type-assertions": "off",
|
||||
"@typescript-eslint/strict-boolean-expressions": "off",
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
import path from 'path'
|
||||
import { findPackages } from '@pnpm/fs.find-packages'
|
||||
|
||||
function compare (a: string | undefined, b: string | undefined) {
|
||||
if (a == null) return 1
|
||||
if (b == null) return -1
|
||||
return a.localeCompare(b)
|
||||
}
|
||||
|
||||
const fixtures = path.join(__dirname, 'fixtures')
|
||||
|
||||
test('finds package', async () => {
|
||||
@@ -22,7 +28,7 @@ test('finds packages by patterns', async () => {
|
||||
expect(pkgs[0].manifest).toBeDefined()
|
||||
expect(pkgs[1].dir).toBeDefined()
|
||||
expect(pkgs[1].manifest).toBeDefined()
|
||||
expect([pkgs[0].manifest.name, pkgs[1].manifest.name].sort()).toStrictEqual(['component-1', 'component-2'])
|
||||
expect([pkgs[0].manifest.name, pkgs[1].manifest.name].sort(compare)).toStrictEqual(['component-1', 'component-2'])
|
||||
})
|
||||
|
||||
test('finds packages by * pattern', async () => {
|
||||
@@ -30,7 +36,7 @@ test('finds packages by * pattern', async () => {
|
||||
const pkgs = await findPackages(root, { patterns: ['.', 'components/*'] })
|
||||
|
||||
expect(pkgs).toHaveLength(3)
|
||||
expect([pkgs[0].manifest.name, pkgs[1].manifest.name, pkgs[2].manifest.name].sort()).toStrictEqual(['component-1', 'component-2', 'many-pkgs-2'])
|
||||
expect([pkgs[0].manifest.name, pkgs[1].manifest.name, pkgs[2].manifest.name].sort(compare)).toStrictEqual(['component-1', 'component-2', 'many-pkgs-2'])
|
||||
})
|
||||
|
||||
test('finds packages by default pattern', async () => {
|
||||
@@ -38,7 +44,7 @@ test('finds packages by default pattern', async () => {
|
||||
const pkgs = await findPackages(root)
|
||||
|
||||
expect(pkgs).toHaveLength(4)
|
||||
expect(pkgs.map(({ manifest }) => manifest.name).sort()).toStrictEqual(['component-1', 'component-2', 'foo', 'many-pkgs-2'])
|
||||
expect(pkgs.map(({ manifest }) => manifest.name).sort(compare)).toStrictEqual(['component-1', 'component-2', 'foo', 'many-pkgs-2'])
|
||||
})
|
||||
|
||||
test('ignore packages by patterns', async () => {
|
||||
@@ -50,7 +56,7 @@ test('ignore packages by patterns', async () => {
|
||||
expect(pkgs[0].manifest).toBeDefined()
|
||||
expect(pkgs[1].dir).toBeDefined()
|
||||
expect(pkgs[1].manifest).toBeDefined()
|
||||
expect([pkgs[0].manifest.name, pkgs[1].manifest.name].sort()).toStrictEqual(['component-1', 'component-2'])
|
||||
expect([pkgs[0].manifest.name, pkgs[1].manifest.name].sort(compare)).toStrictEqual(['component-1', 'component-2'])
|
||||
})
|
||||
|
||||
test('json and yaml manifests are also found', async () => {
|
||||
|
||||
Reference in new issue
Block a user