Skip to content

Commit 3e11731

Browse files
authored
Merge pull request #207 from wojtekmaj/typescript
Migrate to TypeScript
2 parents b8ea206 + bedf0a4 commit 3e11731

59 files changed

Lines changed: 1191 additions & 3898 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.babelrc‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎.eslintrc.js‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎.github/workflows/ci.yml‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ jobs:
1414
name: Lint
1515
runs-on: ubuntu-24.04-arm
1616

17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v6
20+
21+
- name: Setup Biome
22+
uses: biomejs/setup-biome@v2
23+
24+
- name: Run linting
25+
run: biome lint
26+
27+
typescript:
28+
name: Type checking
29+
runs-on: ubuntu-24.04-arm
30+
1731
steps:
1832
- name: Checkout
1933
uses: actions/checkout@v6
@@ -30,8 +44,22 @@ jobs:
3044
- name: Install dependencies
3145
run: pnpm install --frozen-lockfile
3246

33-
- name: Run lint
34-
run: pnpm lint
47+
- name: Run type checking
48+
run: pnpm tsc
49+
50+
format:
51+
name: Format
52+
runs-on: ubuntu-24.04-arm
53+
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v6
57+
58+
- name: Setup Biome
59+
uses: biomejs/setup-biome@v2
60+
61+
- name: Run formatting
62+
run: biome format
3563

3664
unit:
3765
name: Unit tests
@@ -54,7 +82,7 @@ jobs:
5482
run: pnpm install --frozen-lockfile
5583

5684
- name: Run tests
57-
run: pnpm test
85+
run: pnpm unit
5886

5987
build:
6088
name: Build

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ npm-debug.log
2020

2121
# Built files
2222
/index.js
23-
23+
/index.d.ts

‎.prettierrc‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎README.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,15 @@ For implementors, there is also a few extra APIs available.
9494
These are for specific use-cases, and most people should just be using the API above.
9595

9696
```js
97-
import { getPropertyName, getStylesForProperty } from 'css-to-react-native';
97+
import {
98+
getPropertyName,
99+
getStylesForProperty,
100+
transformRawValue,
101+
} from 'css-to-react-native';
98102

99103
getPropertyName('border-width'); // => 'borderWidth'
100104
getStylesForProperty('borderWidth', '1px 0px 2px 0px'); // => { borderTopWidth: 1, ... }
105+
transformRawValue('opacity', '0.5'); // => 0.5
101106
```
102107

103108
Should you wish to opt-out of transforming certain shorthands, an array of property names in camelCase can be passed as a second argument to `transform`.
@@ -109,6 +114,8 @@ transform([['border-radius', '50px']], ['borderRadius']);
109114

110115
This can also be done by passing a third argument, `false` to `getStylesForProperty`.
111116

117+
`transformRawValue` is a lower-level helper that parses a single raw value without applying shorthand expansion.
118+
112119
## License
113120

114121
Licensed under the MIT License, Copyright © 2019 Krister Kari, Jacob Parker, and Maximilian Stoiber.

‎biome.json‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.4.9/schema.json",
3+
"files": {
4+
"includes": ["src/**"]
5+
},
6+
"assist": {
7+
"actions": {
8+
"source": {
9+
"organizeImports": "on"
10+
}
11+
}
12+
},
13+
"formatter": {
14+
"indentStyle": "space"
15+
},
16+
"linter": {
17+
"rules": {
18+
"correctness": {
19+
"noUnusedImports": "warn",
20+
"noUnusedVariables": {
21+
"level": "warn",
22+
"options": {
23+
"ignoreRestSiblings": true
24+
}
25+
}
26+
},
27+
"suspicious": {
28+
"noConsole": "warn"
29+
}
30+
}
31+
},
32+
"css": {
33+
"formatter": {
34+
"quoteStyle": "single"
35+
}
36+
},
37+
"javascript": {
38+
"formatter": {
39+
"quoteStyle": "single",
40+
"semicolons": "asNeeded",
41+
"trailingCommas": "es5"
42+
}
43+
}
44+
}

‎index.d.ts‎

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎package.json‎

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@
44
"description": "Convert CSS text to a React Native stylesheet object",
55
"main": "index.js",
66
"types": "index.d.ts",
7+
"sideEffects": false,
78
"scripts": {
8-
"build": "rollup ./src/index.js -o index.js --f cjs && babel index.js -o index.js",
9-
"test": "vitest",
10-
"test:watch": "vitest --watch",
11-
"lint": "eslint src",
12-
"prepublish": "npm run build",
9+
"build": "rollup -c",
10+
"clean": "node -e \"fs.rmSync('./index.js', { force: true }); fs.rmSync('./index.d.ts', { force: true })\"",
11+
"format": "biome format",
12+
"lint": "biome lint",
1313
"precommit": "lint-staged",
14-
"lint-staged": "lint-staged"
14+
"prebuild": "pnpm clean && pnpm tsc",
15+
"prepack": "pnpm build",
16+
"test": "pnpm lint && pnpm tsc && pnpm format && pnpm unit",
17+
"tsc": "tsc",
18+
"unit": "vitest",
19+
"unit:watch": "vitest --watch"
1520
},
1621
"files": [
1722
"index.js",
@@ -36,17 +41,14 @@
3641
},
3742
"homepage": "https://github.com/styled-components/css-to-react-native#readme",
3843
"devDependencies": {
39-
"@babel/cli": "^7.6.2",
40-
"@babel/core": "^7.1.0",
41-
"@babel/preset-env": "^7.6.2",
42-
"eslint": "^4.17.0",
43-
"eslint-config-airbnb-base": "^12.1.0",
44-
"eslint-config-prettier": "^2.9.0",
45-
"eslint-plugin-import": "^2.8.0",
46-
"eslint-plugin-prettier": "^2.6.0",
44+
"@types/node": "^24.7.2",
45+
"@rollup/plugin-typescript": "^12.1.2",
46+
"@biomejs/biome": "2.4.9",
4747
"lint-staged": "^6.1.0",
48-
"prettier": "^1.18.2",
49-
"rollup": "^1.22.0",
48+
"rollup": "^4.40.2",
49+
"rollup-plugin-dts": "^6.2.1",
50+
"tslib": "^2.8.1",
51+
"typescript": "^6.0.2",
5052
"vitest": "^4.0.1"
5153
},
5254
"dependencies": {
@@ -55,8 +57,8 @@
5557
"postcss-value-parser": "^4.0.2"
5658
},
5759
"lint-staged": {
58-
"*.js": [
59-
"eslint --fix",
60+
"*.{js,ts}": [
61+
"biome check",
6062
"git add"
6163
]
6264
},

0 commit comments

Comments
 (0)