Skip to content

Commit 096cbbd

Browse files
committed
fix: warn on unknown variants
1 parent 16a0c5d commit 096cbbd

9 files changed

+1436
-245
lines changed

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Provides editor support for ```tw`...```` tagged template syntax including:
3636
- Autocomplete for [twind](https://github.com/tw-in-js/twind) classes
3737
- Warnings on unknown classes
3838
- Warnings on unknown theme values
39+
- Warnings on unknown variants
3940

4041
## Installation
4142

@@ -47,6 +48,30 @@ npm install --save-dev typescript @twind/typescript-plugin
4748

4849
This plugin requires TypeScript 4.1 or later. It can provide intellisense in both JavaScript and TypeScript files within any editor that uses TypeScript to power their language features. This includes [VS Code](https://code.visualstudio.com), [Sublime with the TypeScript plugin](https://github.com/Microsoft/TypeScript-Sublime-Plugin), [Atom with the TypeScript plugin](https://atom.io/packages/atom-typescript), [Visual Studio](https://www.visualstudio.com), and others.
4950

51+
If you have a custom twind configuration you need to extract that into an own file. Create a `twind.config.{ts,js,cjs,mjs}` in your root folder. Here is using a custom plugin:
52+
53+
```js
54+
import { forms, formInput } from '@twind/forms'
55+
56+
/** @type {import('twind').Configuration} */
57+
export default {
58+
plugins: { forms, 'form-input': formInput}
59+
}
60+
61+
declare module 'twind' {
62+
interface Plugins {
63+
// forms should have been detected from setup – not need to add it
64+
// forms: ''
65+
66+
// We want to add sm and lg modifiers to the form-input
67+
'form-input':
68+
| '' // plain form-input
69+
| 'sm' // form-input-sm
70+
| 'lg' // form-input-lg
71+
}
72+
}
73+
```
74+
5075
### With VS Code
5176

5277
Currently you must manually install the plugin along side TypeScript in your workspace.

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
"build": "distilt",
3131
"format": "prettier --write --ignore-path .gitignore .",
3232
"lint": "eslint --ext .js,.ts --ignore-path .gitignore .",
33+
"postlint": "tsc",
3334
"lint:fix": "yarn lint -- --fix",
35+
"test": "uvu -r esm -r test-env.js",
36+
"test:watch": "watchlist src -- yarn test",
3437
"release": "npx np --contents dist",
3538
"version": "yarn build"
3639
},
@@ -108,11 +111,15 @@
108111
"@typescript-eslint/eslint-plugin": "^4.9.1",
109112
"@typescript-eslint/parser": "^4.9.1",
110113
"distilt": "^0.10.1",
114+
"esbuild-register": "^2.3.0",
111115
"eslint": "^7.15.0",
112116
"eslint-config-prettier": "^7.0.0",
113117
"eslint-plugin-prettier": "^3.2.0",
118+
"esm": "^3.2.25",
114119
"execa": "^5.0.0",
115-
"prettier": "^2.0.5"
120+
"prettier": "^2.0.5",
121+
"uvu": "^0.5.1",
122+
"watchlist": "^0.2.3"
116123
},
117124
"publishConfig": {
118125
"access": "public",

0 commit comments

Comments
 (0)