Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Oct 11, 2024
1 parent 1b4acbc commit 6ca7fa9
Show file tree
Hide file tree
Showing 32 changed files with 1,194 additions and 163 deletions.
5 changes: 5 additions & 0 deletions .vscode/dictionary.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
antfu
attributify
biomejs
booleanish
bumpp
bunx
changelogen
changelogithub
classname
codecov
commitlint
commitlintrc
Expand All @@ -27,7 +29,10 @@ socio
Solana
Spatie
stacksjs
synckit
TSES
typecheck
unocss
unplugin
unref
upath
Expand Down
101 changes: 4 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,100 +1,7 @@
<p align="center"><img src=".github/art/cover.jpg" alt="Social Card of this repo"></p>
# @unocss/eslint-plugin

[![npm version][npm-version-src]][npm-version-href]
[![GitHub Actions][github-actions-src]][github-actions-href]
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
<!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
<!-- [![Codecov][codecov-src]][codecov-href] -->
ESLint plugin for UnoCSS.

# bun-ts-starter
## Documentation

This is an opinionated TypeScript Starter kit to help kick-start development of your next Bun package.

## Get Started

It's rather simple to get your package development started:

```bash
# you may use this GitHub template or the following command:
bunx degit stacksjs/ts-starter my-pkg
cd my-pkg

# if you don't have pnpm installed, run `npm i -g pnpm`
bun i # install all deps
bun run build # builds the library for production-ready use

# how to create a git commit?
git add . # select the changes you want to commit
bun run commit # then simply answer the questions

# after you have successfully committed, you may create a "release"
bun run release # automates git commits, versioning, and changelog generations
```

_Check out the package.json scripts for more commands._

### Developer Experience (DX)

This Starter Kit comes pre-configured with the following:

- [Powerful Build Process](https://github.com/oven-sh/bun) - via Bun
- [Fully Typed APIs](https://www.typescriptlang.org/) - via TypeScript
- [Be a Good Commitizen](https://www.npmjs.com/package/git-cz) - pre-configured Commitizen & git-cz setup to simplify semantic git commits, versioning, and changelog generations
- [Built With Testing In Mind](https://bun.sh/docs/cli/test) - pre-configured unit-testing powered by [Bun](https://bun.sh/docs/cli/test)
- [Renovate](https://renovatebot.com/) - optimized & automated PR dependency updates
- [Biome](https://biomejs.dev/) - an instant, fast linter & formatter for JavaScript, TypeScript, and CSS
- [GitHub Actions](https://github.com/features/actions) - runs your CI _(fixes code style issues, tags releases & creates its changelogs, runs the test suite, etc.)_

## Testing

```bash
bun test
```

## Changelog

Please see our [releases](https://github.com/stackjs/bun-ts-starter/releases) page for more information on what has changed recently.

## Contributing

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

## Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

[Discussions on GitHub](https://github.com/stacksjs/ts-starter/discussions)

For casual chit-chat with others using this package:

[Join the Stacks Discord Server](https://discord.gg/stacksjs)

## Postcardware

Stacks OSS will always stay open-sourced, and we will always love to receive postcards from wherever Stacks is used! _And we also publish them on our website. Thank you, Spatie._

Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎

## Sponsors

We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.

- [JetBrains](https://www.jetbrains.com/)
- [The Solana Foundation](https://solana.com/)

## 📄 License

The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.

Made with 💙

<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/bun-ts-starter?style=flat-square
[npm-version-href]: https://npmjs.com/package/bun-ts-starter
[npm-downloads-src]: https://img.shields.io/npm/dm/bun-ts-starter?style=flat-square
[npm-downloads-href]: https://npmjs.com/package/bun-ts-starter
[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/ts-starter/ci.yml?style=flat-square&branch=main
[github-actions-href]: https://github.com/stacksjs/ts-starter/actions?query=workflow%3Aci

<!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/ts-starter/main?style=flat-square
[codecov-href]: https://codecov.io/gh/stacksjs/ts-starter -->
Please refer to the [documentation](https://unocss.dev/integrations/eslint).
30 changes: 30 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig([
{
entries: [
'src/worker',
],
clean: true,
failOnWarn: false,
},
{
entries: [
'src/dirs',
'src/index',
],
clean: false,
declaration: true,
rollup: {
emitCJS: true,
dts: {
respectExternal: true,
},
},
externals: [
'@typescript-eslint/utils/ts-eslint',
'@typescript-eslint/utils',
'@typescript-eslint/types',
],
},
])
9 changes: 0 additions & 9 deletions build.ts

This file was deleted.

Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions fixtures/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.eslintrc.json
15 changes: 15 additions & 0 deletions fixtures/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import antfu from '@antfu/eslint-config'
import unocss from '@unocss/eslint-plugin'

export default antfu(
{
unocss: false,
svelte: true
},
unocss.configs.flat,
{
rules: {
'unocss/blocklist': 'error',
}
}
)
1 change: 1 addition & 0 deletions fixtures/src/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1 class="text-3xl hover:text-red m1 font-bold underline">Hello world!</h1>
24 changes: 24 additions & 0 deletions fixtures/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<div flex="~ gap-1 cols">
<div class="hover:text-red text-4xl mx1 m2">
<div i-carbon-campsite inline-block />
</div>
<p>
<a rel="noreferrer" href="https://github.com/antfu/vitesse" target="_blank">
Vitesse
</a>
</p>
<p>
<em text-sm opacity-75 class="foo" hover:text-red text-4xl mx1 m2>{{ t('intro.desc') }}</em>
</p>

<div class="hover:(text-red text-4xl) hover:mx1 mx1 m2">Variant group</div>

<div class="
foo bar
hover:(text-red text-4xl)
hover:mx1 mx1 m2
blocked-rule
" blocked-rule-attr></div>
</div>
</template>
7 changes: 7 additions & 0 deletions fixtures/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function App() {
return (
<h1 className="text-3xl hover:text-red m1 font-bold underline">
Hello world!
</h1>
)
}
25 changes: 25 additions & 0 deletions fixtures/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": [
"src"
]
}
14 changes: 14 additions & 0 deletions fixtures/uno.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// eslint-disable-next-line no-restricted-imports
import { defineConfig, presetUno, transformerVariantGroup } from 'unocss'

export default defineConfig({
presets: [
presetUno(),
],
transformers: [
transformerVariantGroup(),
],
blocklist: [
[(i) => i.includes('blocked'), { message: 'use non-blocked-rule' }]
]
})
89 changes: 38 additions & 51 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,69 +1,56 @@
{
"name": "bun-ts-starter",
"name": "@stacksjs/eslint-plugin",
"type": "module",
"version": "0.4.0",
"description": "A simple TypeScript starter kit using Bun.",
"author": "Chris Breuer <[email protected]>",
"version": "0.63.4-stacks.0",
"description": "The Stacks ESLint plugin",
"license": "MIT",
"homepage": "https://github.com/stacksjs/ts-starter#readme",
"funding": "https://github.com/sponsors/chrisbbreuer",
"homepage": "https://github.com/stacksjs/eslint-plugin",
"repository": {
"type": "git",
"url": "git+https://github.com/stacksjs/ts-starter.git"
"url": "https://github.com/stacksjs/eslint-plugin"
},
"bugs": {
"url": "https://github.com/stacksjs/ts-starter/issues"
"url": "https://github.com/unocss/unocss/issues"
},
"keywords": ["typescript", "starter", "kit", "bun", "package"],
"keywords": [
"eslint-plugin",
"eslint"
],
"sideEffects": false,
"exports": {
".": {
"bun": "./src/index.ts",
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./*": {
"bun": "./src/*",
"import": "./dist/*"
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": ["dist", "src"],
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"files": [
"dist"
],
"engines": {
"node": ">=14"
},
"scripts": {
"build": "bun --bun build.ts",
"lint": "biome check .",
"lint:fix": "biome check --fix .",
"fresh": "bunx rimraf node_modules/ bun.lock && bun i",
"commit": "git cz",
"changelog": "bunx changelogen --output CHANGELOG.md",
"prepublishOnly": "bun --bun run build",
"release": "bun run changelog && bunx bumpp package.json --all",
"test": "bun test",
"typecheck": "bun --bun tsc --noEmit"
"build": "unbuild",
"typecheck": "tsc --noEmit",
"lint": "nr build && cd ./fixtures && eslint ./src"
},
"dependencies": {
"@typescript-eslint/utils": "^8.8.1",
"@unocss/config": "0.61.0",
"@unocss/core": "0.61.0",
"magic-string": "^0.30.12",
"synckit": "^0.9.2",
"unocss": "0.61.0"
},
"devDependencies": {
"@biomejs/biome": "^1.9.3",
"@commitlint/cli": "^19.5.0",
"@stacksjs/biome-config": "^0.1.5",
"@types/bun": "^1.1.11",
"bumpp": "^9.7.1",
"bun-plugin-dts-auto": "^0.20.6",
"changelogen": "^0.5.7",
"commitizen": "^4.3.1",
"cz-git": "^1.10.1",
"lint-staged": "^15.2.10",
"simple-git-hooks": "^2.11.1",
"typescript": "^5.6.3"
},
"simple-git-hooks": {
"pre-commit": "bun lint-staged",
"commit-msg": "bunx --no -- commitlint --edit $1"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,vue}": "biome check --fix ."
},
"config": {
"commitizen": {
"path": "node_modules/cz-git"
}
"@types/node": "^22.7.5",
"unbuild": "2.0.0",
"eslint-vitest-rule-tester": "^0.6.1",
"vitest": "^2.1.2",
"vue-eslint-parser": "^9.4.3"
}
}
11 changes: 11 additions & 0 deletions src/configs/flat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { plugin } from '../plugin'

export default {
plugins: {
unocss: plugin,
},
rules: {
'unocss/order': 'warn',
'unocss/order-attributify': 'warn',
} as const,
}
7 changes: 7 additions & 0 deletions src/configs/recommended.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
plugins: ['@unocss'],
rules: {
'@unocss/order': 'warn',
'@unocss/order-attributify': 'warn',
} as const,
}
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const CLASS_FIELDS = ['class', 'classname']
export const AST_NODES_WITH_QUOTES = ['Literal', 'VLiteral']
3 changes: 3 additions & 0 deletions src/dirs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { fileURLToPath } from 'node:url'

export const distDir = fileURLToPath(new URL('../dist', import.meta.url))
Loading

0 comments on commit 6ca7fa9

Please sign in to comment.