Skip to content

Commit be5c999

Browse files
author
nyxb
committed
🔧 chore(.eslintrc): disable @next/next/no-html-link-for-pages rule and set React version to 16.0
🔧 chore(package.json): add @nyxb/nyxi to devDependencies and update scripts ✅ test(magicase.test.ts): add tests for string manipulation functions The changes in .eslintrc disable a rule that is not applicable to the project and set the React version to 16.0. In package.json, @nyxb/nyxi is added to devDependencies and the scripts are updated to include new commands for building, linting, and testing. The new file magicase.test.ts contains tests for string manipulation functions.
1 parent ba31948 commit be5c999

File tree

4 files changed

+127
-2
lines changed

4 files changed

+127
-2
lines changed

‎.eslintrc‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{
22
"extends": [
33
"@nyxb"
4-
]
4+
],
5+
"rules": {
6+
"@next/next/no-html-link-for-pages": 0
7+
},
8+
"settings": {
9+
"react": {
10+
"version": "16.0"
11+
}
12+
}
513
}

‎package.json‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,17 @@
2525
"./*": "./*"
2626
},
2727
"scripts": {
28-
"test": "echo \"Happy hacking\" && 💙"
28+
"prepack": "nyxr build",
29+
"build": "unbuild",
30+
"dev": "vitest dev",
31+
"lint": "eslint --cache --ext .ts,.js,.mjs,.cjs .",
32+
"lint:fix": "eslint --cache --ext .ts,.js,.mjs,.cjs . --fix",
33+
"release": "nyxr test && nyxlx changelogen@latest --release --push && pnpm publish",
34+
"test": "nyxr lint && vitest run --coverage"
2935
},
3036
"devDependencies": {
3137
"@nyxb/eslint-config": "^0.0.53",
38+
"@nyxb/nyxi": "^0.0.28",
3239
"@types/node": "^18.16.8",
3340
"@vitest/coverage-c8": "^0.31.0",
3441
"eslint": "^8.40.0",

‎pnpm-lock.yaml‎

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎test/magicase.test.ts‎

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { describe, expect, test } from 'vitest'
2+
import {
3+
camelCase,
4+
kebabCase,
5+
lowerFirst,
6+
pascalCase,
7+
snakeCase,
8+
splitByCase,
9+
upperFirst,
10+
} from '../src'
11+
12+
describe('splitByCase', () => {
13+
test.each([
14+
['', []],
15+
['foo', ['foo']],
16+
['fooBar', ['foo', 'Bar']],
17+
['FooBarBaz', ['Foo', 'Bar', 'Baz']],
18+
['foo_bar-baz/qux', ['foo', 'bar', 'baz', 'qux']],
19+
['foo--bar-Baz', ['foo', '', 'bar', 'Baz']],
20+
['foo123-bar', ['foo123', 'bar']],
21+
['FOOBar', ['FOO', 'Bar']],
22+
['ALink', ['A', 'Link']],
23+
// with custom splitters
24+
[
25+
'foo\\Bar.fuzz-FIZz',
26+
['foo', 'Bar', 'fuzz', 'FI', 'Zz'],
27+
['\\', '.', '-'],
28+
],
29+
])('%s => %s', (input, expected, customSplitters?) => {
30+
if (customSplitters)
31+
expect(splitByCase(input, customSplitters)).toMatchObject(expected)
32+
33+
else
34+
expect(splitByCase(input)).toMatchObject(expected)
35+
})
36+
})
37+
38+
describe('pascalCase', () => {
39+
test.each([
40+
['', ''],
41+
['foo', 'Foo'],
42+
['foo-bAr', 'FooBAr'],
43+
['FooBARb', 'FooBARb'],
44+
['foo_bar-baz/qux', 'FooBarBazQux'],
45+
['foo--bar-Baz', 'FooBarBaz'],
46+
])('%s => %s', (input, expected) => {
47+
expect(pascalCase(input)).toMatchObject(expected)
48+
})
49+
})
50+
51+
describe('camelCase', () => {
52+
test.each([['FooBarBaz', 'fooBarBaz']])('%s => %s', (input, expected) => {
53+
expect(camelCase(input)).toMatchObject(expected)
54+
})
55+
})
56+
57+
describe('kebabCase', () => {
58+
test.each([
59+
['', ''],
60+
['foo', 'foo'],
61+
['foo/Bar', 'foo-bar'],
62+
['foo-bAr', 'foo-b-ar'],
63+
['foo--bar', 'foo--bar'],
64+
['FooBAR', 'foo-bar'],
65+
['ALink', 'a-link'],
66+
])('%s => %s', (input, expected) => {
67+
expect(kebabCase(input)).toMatchObject(expected)
68+
})
69+
})
70+
71+
describe('snakeCase', () => {
72+
test.each([['FooBarBaz', 'foo_bar_baz']])('%s => %s', (input, expected) => {
73+
expect(snakeCase(input)).toMatchObject(expected)
74+
})
75+
})
76+
77+
describe('upperFirst', () => {
78+
test.each([
79+
['', ''],
80+
['foo', 'Foo'],
81+
['Foo', 'Foo'],
82+
])('%s => %s', (input, expected) => {
83+
expect(upperFirst(input)).toMatchObject(expected)
84+
})
85+
})
86+
87+
describe('lowerFirst', () => {
88+
test.each([
89+
['', ''],
90+
['foo', 'foo'],
91+
['Foo', 'foo'],
92+
])('%s => %s', (input, expected) => {
93+
expect(lowerFirst(input)).toMatchObject(expected)
94+
})
95+
})

0 commit comments

Comments
 (0)