Skip to content

Commit

Permalink
fix: warn on unknown variants
Browse files Browse the repository at this point in the history
  • Loading branch information
sastan committed Mar 16, 2021
1 parent 16a0c5d commit 096cbbd
Show file tree
Hide file tree
Showing 9 changed files with 1,436 additions and 245 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Provides editor support for ```tw`...```` tagged template syntax including:
- Autocomplete for [twind](https://github.com/tw-in-js/twind) classes
- Warnings on unknown classes
- Warnings on unknown theme values
- Warnings on unknown variants

## Installation

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

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.

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:

```js
import { forms, formInput } from '@twind/forms'

/** @type {import('twind').Configuration} */
export default {
plugins: { forms, 'form-input': formInput}
}

declare module 'twind' {
interface Plugins {
// forms should have been detected from setup – not need to add it
// forms: ''

// We want to add sm and lg modifiers to the form-input
'form-input':
| '' // plain form-input
| 'sm' // form-input-sm
| 'lg' // form-input-lg
}
}
```

### With VS Code

Currently you must manually install the plugin along side TypeScript in your workspace.
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"build": "distilt",
"format": "prettier --write --ignore-path .gitignore .",
"lint": "eslint --ext .js,.ts --ignore-path .gitignore .",
"postlint": "tsc",
"lint:fix": "yarn lint -- --fix",
"test": "uvu -r esm -r test-env.js",
"test:watch": "watchlist src -- yarn test",
"release": "npx np --contents dist",
"version": "yarn build"
},
Expand Down Expand Up @@ -108,11 +111,15 @@
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"distilt": "^0.10.1",
"esbuild-register": "^2.3.0",
"eslint": "^7.15.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-prettier": "^3.2.0",
"esm": "^3.2.25",
"execa": "^5.0.0",
"prettier": "^2.0.5"
"prettier": "^2.0.5",
"uvu": "^0.5.1",
"watchlist": "^0.2.3"
},
"publishConfig": {
"access": "public",
Expand Down

0 comments on commit 096cbbd

Please sign in to comment.