Skip to content

Commit 57a6d44

Browse files
committed
initial commit
0 parents  commit 57a6d44

23 files changed

+8923
-0
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# editorconfig.org
2+
root = true
3+
4+
# All files should use
5+
# - tabs unless specified otherwise
6+
# - unix-style newlines with a newline ending every file
7+
[*]
8+
indent_style = space
9+
indent_size = 2
10+
end_of_line = lf
11+
charset = utf-8
12+
trim_trailing_whitespace = true
13+
insert_final_newline = true
14+
15+
[*.md]
16+
trim_trailing_whitespace = false

.github/workflows/main.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: CI
2+
on: [push]
3+
jobs:
4+
build:
5+
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}
6+
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
node: ['14.x']
11+
os: [ubuntu-latest]
12+
13+
steps:
14+
- name: Checkout 🛎️
15+
uses: actions/checkout@v2
16+
17+
- name: Use Node ${{ matrix.node }}
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: ${{ matrix.node }}
21+
22+
- name: Install 🔧
23+
uses: bahmutov/npm-install@v1
24+
25+
- name: Test
26+
run: yarn run ci
27+
28+
- name: Build
29+
run: yarn run build
30+
31+
- name: Coveralls
32+
uses: coverallsapp/github-action@master
33+
with:
34+
github-token: ${{ secrets.GITHUB_TOKEN }}
35+
flag-name: build-${{ matrix.node }}-${{ matrix.os }}
36+
parallel: true
37+
38+
finish:
39+
needs: build
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Coveralls Finished
43+
uses: coverallsapp/github-action@master
44+
with:
45+
github-token: ${{ secrets.github_token }}
46+
parallel-finished: true

.gitignore

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
.build
2+
build
3+
node_modules
4+
web_modules
5+
6+
.cache
7+
dist
8+
__generated__
9+
10+
docs
11+
!packages/*/docs
12+
13+
benchmarks/*.min.mjs
14+
15+
# Svelte Component type defs
16+
*.svelte.tsx
17+
__svelte-jsx.d.ts
18+
__svelte-shims.d.ts
19+
20+
# Logs
21+
logs
22+
*.log
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
lerna-debug.log*
27+
28+
# Diagnostic reports (https://nodejs.org/api/report.html)
29+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
30+
31+
# Runtime data
32+
pids
33+
*.pid
34+
*.seed
35+
*.pid.lock
36+
37+
# Directory for instrumented libs generated by jscoverage/JSCover
38+
lib-cov
39+
40+
# Coverage directory used by tools like istanbul
41+
coverage/
42+
*.lcov
43+
44+
# nyc test coverage
45+
.nyc_output
46+
47+
# Dependency directories
48+
node_modules/
49+
jspm_packages/
50+
51+
# TypeScript v1 declaration files
52+
typings/
53+
54+
# TypeScript cache
55+
*.tsbuildinfo
56+
57+
# Optional npm cache directory
58+
.npm
59+
60+
# Optional eslint cache
61+
.eslintcache
62+
63+
# Optional REPL history
64+
.node_repl_history
65+
66+
# Output of 'npm pack'
67+
*.tgz
68+
69+
# Yarn Integrity file
70+
.yarn-integrity

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry = https://registry.npmjs.org/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v14

.vscode/extensions.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"recommendations": [
3+
"Orta.vscode-jest",
4+
"esbenp.prettier-vscode",
5+
"dbaeumer.vscode-eslint",
6+
"drknoxy.eslint-disable-snippets",
7+
"eg2.vscode-npm-script",
8+
"visualstudioexptteam.vscodeintellicode"
9+
]
10+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib"
3+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 [these people](https://github.com/tw-in-js/typescript-plugin/graphs/contributors)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# @tw-in-js/typescript-plugin
2+
3+
> TypeScript language service plugin that adds IntelliSense for tailwindjs
4+
5+
[![MIT License](https://flat.badgen.net/github/license/tw-in-js/typescript-plugin)](https://github.com/tw-in-js/core/blob/main/LICENSE)
6+
[![Latest Release](https://flat.badgen.net/npm/v/@tw-in-js/typescript-plugin?icon=npm&label)](https://www.npmjs.com/package/@tw-in-js/typescript-plugin)
7+
[![Github](https://flat.badgen.net/badge/icon/tw-in-js%2Ftypescript-plugin?icon=github&label)](https://github.com/tw-in-js/typescript-plugin)
8+
9+
---
10+
11+
<!-- prettier-ignore-start -->
12+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
13+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
14+
15+
16+
- [Features](#features)
17+
- [Installation](#installation)
18+
- [Usage](#usage)
19+
- [Configuration](#configuration)
20+
- [Contribute](#contribute)
21+
- [License](#license)
22+
23+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
24+
<!-- prettier-ignore-end -->
25+
26+
## Features
27+
28+
Provides editor support for ```tw`...```` tagged template syntax including:
29+
30+
- Autocomplete for tailwind, beamwind and oceanwin classes
31+
- Warnings on unknown classes
32+
- Quick fixes for misspelled property names.
33+
34+
## Installation
35+
36+
```sh
37+
npm install --save-dev @tw-in-js/typescript-plugin
38+
```
39+
40+
## Usage
41+
42+
This plugin requires TypeScript 2.4 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.
43+
44+
### With VS Code
45+
46+
Just install the [VS Code tailwindjs extension](https://github.com/tw-in-js/core/packages/vscode). This extension adds syntax highlighting and IntelliSense for styled components in JavaScript and TypeScript files.
47+
48+
If you are using a [workspace version of TypeScript](<(https://code.visualstudio.com/Docs/languages/typescript#_using-newer-typescript-versions)>) however, you must manually install the plugin along side the version of TypeScript in your workspace.
49+
50+
Then add a `plugins` section to your [`tsconfig.json`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or [`jsconfig.json`](https://code.visualstudio.com/Docs/languages/javascript#_javascript-project-jsconfigjson)
51+
52+
```json
53+
{
54+
"compilerOptions": {
55+
"plugins": [
56+
{
57+
"name": "@tw-in-js/typescript-plugin"
58+
}
59+
]
60+
}
61+
}
62+
```
63+
64+
Finally, run the `Select TypeScript version` command in VS Code to switch to use the workspace version of TypeScript for VS Code's JavaScript and TypeScript language support. You can find more information about managing typescript versions [in the VS Code documentation](https://code.visualstudio.com/Docs/languages/typescript#_using-newer-typescript-versions).
65+
66+
### With Sublime
67+
68+
This plugin works with the [Sublime TypeScript plugin](https://github.com/Microsoft/TypeScript-Sublime-Plugin).
69+
70+
And configure Sublime to use the workspace version of TypeScript by [setting the `typescript_tsdk`](https://github.com/Microsoft/TypeScript-Sublime-Plugin#note-using-different-versions-of-typescript) setting in Sublime:
71+
72+
```json
73+
{
74+
"typescript_tsdk": "/path/to/the/project/node_modules/typescript/lib"
75+
}
76+
```
77+
78+
Finally add a `plugins` section to your [`tsconfig.json`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or [`jsconfig.json`](https://code.visualstudio.com/Docs/languages/javascript#_javascript-project-jsconfigjson) and restart Sublime.
79+
80+
```json
81+
{
82+
"compilerOptions": {
83+
"plugins": [
84+
{
85+
"name": "@tw-in-js/typescript-plugin"
86+
}
87+
]
88+
}
89+
}
90+
```
91+
92+
### With Atom
93+
94+
This plugin works with the [Atom TypeScript plugin](https://atom.io/packages/atom-typescript).
95+
96+
Then add a `plugins` section to your [`tsconfig.json`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or [`jsconfig.json`](https://code.visualstudio.com/Docs/languages/javascript#_javascript-project-jsconfigjson) and restart Atom.
97+
98+
```json
99+
{
100+
"compilerOptions": {
101+
"plugins": [
102+
{
103+
"name": "@tw-in-js/typescript-plugin"
104+
}
105+
]
106+
}
107+
}
108+
```
109+
110+
To get sytnax highlighting for styled strings in Atom, consider installing the [language-babel](https://atom.io/packages/language-babel) extension.
111+
112+
### With Visual Studio
113+
114+
This plugin works [Visual Studio 2017](https://www.visualstudio.com) using the TypeScript 2.5+ SDK.
115+
116+
Then add a `plugins` section to your [`tsconfig.json`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
117+
118+
```json
119+
{
120+
"compilerOptions": {
121+
"plugins": [
122+
{
123+
"name": "@tw-in-js/typescript-plugin"
124+
}
125+
]
126+
}
127+
}
128+
```
129+
130+
Then reload your project to make sure the plugin has been loaded properly. Note that `jsconfig.json` projects are currently not supported in VS.
131+
132+
## Configuration
133+
134+
### Tags
135+
136+
This plugin adds IntelliSense to any template literal [tagged](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) with `tw`, `ow` or `bw`:
137+
138+
```js
139+
import { bw } from 'beamwind'
140+
141+
bw`
142+
sm:hover:(
143+
bg-black
144+
text-white
145+
)
146+
md:(bg-white hover:text-black)
147+
`
148+
```
149+
150+
You can enable IntelliSense for other tag names by configuring `"tags"`:
151+
152+
```json
153+
{
154+
"compilerOptions": {
155+
"plugins": [
156+
{
157+
"name": "@tw-in-js/typescript-plugin",
158+
"tags": ["tw", "cx"]
159+
}
160+
]
161+
}
162+
}
163+
```
164+
165+
Now strings tagged with either `tw` and `cx` will have IntelliSense.
166+
167+
## Contribute
168+
169+
Thanks for being willing to contribute!
170+
171+
> This project is free and open-source, so if you think this project can help you or anyone else, you may [star it on GitHub](https://github.com/tw-in-js/core). Feel free to [open an issue](https://github.com/tw-in-js/core/issues) if you have any idea, question, or you've found a bug.
172+
173+
**Working on your first Pull Request?** You can learn how from this _free_ series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)
174+
175+
We are following the [Conventional Commits](https://www.conventionalcommits.org) convention.
176+
177+
### Develop
178+
179+
> Ensure you run at least Node v14.
180+
181+
Clone the repository and cd into the project directory.
182+
183+
Run `yarn install && yarn build`.
184+
185+
- `yarn test`: Run test suite including linting
186+
- `yarn format`: Ensure consistent code style
187+
- `yarn build`: Build the package
188+
- `yarn release`: To publish the package
189+
190+
### Manual testing the Language service plugin
191+
192+
You can check manually language service plugin features with our example project.
193+
194+
```
195+
yarn build
196+
cd dist
197+
yarn link
198+
cd project-fixtures/react-apollo-prj
199+
yarn install
200+
yarn link @tw-in-js/typescript-plugin
201+
code . # Or launch editor/IDE what you like
202+
```
203+
204+
Of course, you can use other editor which communicates with tsserver .
205+
206+
## License
207+
208+
[MIT](https://github.com/tw-in-js/typescript-plugin/blob/main/LICENSE)

package-scripts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@carv/esbundle/nps-preset')

0 commit comments

Comments
 (0)