-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 785b7be
Showing
20 changed files
with
9,627 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_size = 2 | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install dependencies | ||
run: npx nypm@latest i | ||
|
||
- name: Lint | ||
run: npm run lint | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install dependencies | ||
run: npx nypm@latest i | ||
|
||
- name: Test | ||
run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Dependencies | ||
node_modules | ||
|
||
# Logs | ||
*.log* | ||
|
||
# Temp directories | ||
.temp | ||
.tmp | ||
.cache | ||
|
||
# Yarn | ||
**/.yarn/cache | ||
**/.yarn/*state* | ||
|
||
# Generated dirs | ||
dist | ||
|
||
# Nuxt | ||
.nuxt | ||
.output | ||
.data | ||
.vercel_build_output | ||
.build-* | ||
.netlify | ||
|
||
# Env | ||
.env | ||
|
||
# Testing | ||
reports | ||
coverage | ||
*.lcov | ||
.nyc_output | ||
|
||
# VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
!.vscode/*.code-snippets | ||
|
||
# Intellij idea | ||
*.iml | ||
.idea | ||
|
||
# OSX | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
shamefully-hoist=true | ||
strict-peer-dependencies=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
// Disable the default formatter, use eslint instead | ||
"prettier.enable": false, | ||
"editor.formatOnSave": true, | ||
|
||
// Auto fix | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit", | ||
"source.organizeImports": "never" | ||
}, | ||
|
||
// Silent the stylistic rules in you IDE, but still auto fix them | ||
"eslint.rules.customizations": [ | ||
{ "rule": "style/*", "severity": "off" }, | ||
{ "rule": "format/*", "severity": "off" }, | ||
{ "rule": "*-indent", "severity": "off" }, | ||
{ "rule": "*-spacing", "severity": "off" }, | ||
{ "rule": "*-spaces", "severity": "off" }, | ||
{ "rule": "*-order", "severity": "off" }, | ||
{ "rule": "*-dangle", "severity": "off" }, | ||
{ "rule": "*-newline", "severity": "off" }, | ||
{ "rule": "*quotes", "severity": "off" }, | ||
{ "rule": "*semi", "severity": "off" } | ||
], | ||
|
||
// Enable eslint for all supported languages | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
"typescript", | ||
"typescriptreact", | ||
"vue", | ||
"html", | ||
"markdown", | ||
"json", | ||
"jsonc", | ||
"yaml", | ||
"toml", | ||
"xml", | ||
"gql", | ||
"graphql", | ||
"astro", | ||
"css", | ||
"less", | ||
"scss", | ||
"pcss", | ||
"postcss" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Mang | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# es-toolkit for Nuxt | ||
|
||
[![npm version][npm-version-src]][npm-version-href] | ||
[![npm downloads][npm-downloads-src]][npm-downloads-href] | ||
[![License][license-src]][license-href] | ||
[![Nuxt][nuxt-src]][nuxt-href] | ||
|
||
|
||
[es-toolkit](https://es-toolkit.slash.page/) auto-import module for [Nuxt](https://nuxtjs.org). | ||
|
||
## 📦 Install | ||
|
||
Install `nuxt-es-tookit` as development dependency: | ||
|
||
```bash | ||
npm i nuxt-es-tookit -D | ||
``` | ||
|
||
Add it to the `modules` section of your `nuxt.config`: | ||
|
||
```ts | ||
export default defineNuxtConfig({ | ||
modules: ["nuxt-es-tookit"], | ||
}); | ||
``` | ||
|
||
## 🚀 Example | ||
|
||
Use any [es-tookit](https://es-toolkit.slash.page/intro.html) methods in your Nuxt application, they will be auto-imported! | ||
|
||
```html | ||
<script setup> | ||
<template> | ||
<div> | ||
<pre>{{ countBy }}</pre> | ||
<pre>{{ meanBy }}</pre> | ||
<pre>{{ capitalize }}</pre> | ||
</div> | ||
</template> | ||
<script setup> | ||
const fish = [ | ||
{ | ||
name: 'Marlin', | ||
weight: 105, | ||
source: 'ocean', | ||
}, | ||
{ | ||
name: 'Bass', | ||
weight: 8, | ||
source: 'lake', | ||
}, | ||
{ | ||
name: 'Trout', | ||
weight: 1, | ||
source: 'lake', | ||
}, | ||
] | ||
const ra = { | ||
Mode: 'god', | ||
Power: 'sun', | ||
} | ||
// array | ||
const countBy = useCountby(fish, 'weight') | ||
// math | ||
const meanBy = useMeanby(fish, 'weight') | ||
// object | ||
const pick = usePick(ra, ['Mode', 'Power']) | ||
// predicate | ||
const isnil = isNil(ra) | ||
// string | ||
const capitalize = useCapitalize('hello') | ||
</script> | ||
|
||
``` | ||
|
||
## 🔨 Config | ||
|
||
| Name | Default | Description | | ||
| ------------------ | ------- | ------------------------------------------------------------------------------------- | | ||
| `prefix` | `'use'` | String to prepend before each Radash function (false to disable) | | ||
| `prefixSkip` | `'is'` | Functions that starts with this keywords will be skipped by prefix (false to disable) | | ||
| `upperAfterPrefix` | `true` | If true it will automatically uppercase first letter after prefix (false to disable) | | ||
| `alias` | `[]` | Array of array pairs to rename specific Radash functions (prefix is still added) | | ||
|
||
## 💻 Example - Config | ||
|
||
```ts | ||
export default defineNuxtConfig({ | ||
modules: ["nuxt-es-tookit"], | ||
'es-tookit': { | ||
prefix: 'use', | ||
prefixSkip: 'is', | ||
upperAfterPrefix: true, | ||
alias: [ | ||
['snake', 'stringToSnake'], // => stringToSnake | ||
] | ||
} | ||
}); | ||
``` | ||
|
||
## Acknowledgement | ||
The development of `nuxt-es-tookit` was made possible thanks to the inspiration and code base from [nuxt-lodash](https://github.com/cipami/nuxt-lodash). | ||
|
||
## 📄 License | ||
|
||
[MIT License](https://github.com/mangmax/nuxt-es-toolkit/blob/master/LICENSE) © 2024 - [Mang](https://github.com/bbg) | ||
|
||
|
||
<!-- Badges --> | ||
[npm-version-src]: https://img.shields.io/npm/v/my-module/latest.svg?style=flat&colorA=020420&colorB=00DC82 | ||
[npm-version-href]: https://npmjs.com/package/nuxt-es-toolkit | ||
|
||
[npm-downloads-src]: https://img.shields.io/npm/dm/my-module.svg?style=flat&colorA=020420&colorB=00DC82 | ||
[npm-downloads-href]: https://npmjs.com/package/nuxt-es-toolkit | ||
|
||
[license-src]: https://img.shields.io/npm/l/my-module.svg?style=flat&colorA=020420&colorB=00DC82 | ||
[license-href]: https://npmjs.com/package/nuxt-es-toolkit | ||
|
||
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js | ||
[nuxt-href]: https://nuxt.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @ts-check | ||
import { createConfigForNuxt } from '@nuxt/eslint-config/flat' | ||
|
||
// Run `npx @eslint/config-inspector` to inspect the resolved config interactively | ||
export default createConfigForNuxt({ | ||
features: { | ||
// Rules for module authors | ||
tooling: true, | ||
// Rules for formatting | ||
stylistic: true, | ||
}, | ||
dirs: { | ||
src: [ | ||
'./playground', | ||
], | ||
}, | ||
}) | ||
.append( | ||
// your custom flat config here... | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "nuxt-es-toolkit", | ||
"version": "1.0.0", | ||
"description": "es-toolkit for Nuxt", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mangmax/nuxt-es-toolkit" | ||
}, | ||
"license": "MIT", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": "./dist/types.d.ts", | ||
"import": "./dist/module.mjs", | ||
"require": "./dist/module.cjs" | ||
} | ||
}, | ||
"main": "./dist/module.cjs", | ||
"types": "./dist/types.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"prepack": "nuxt-module-build build", | ||
"dev": "nuxi dev playground", | ||
"dev:build": "nuxi build playground", | ||
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground", | ||
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags", | ||
"lint": "eslint .", | ||
"test": "vitest run", | ||
"test:watch": "vitest watch", | ||
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@nuxt/kit": "^3.12.3", | ||
"es-toolkit": "^1.9.0" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/devtools": "^1.3.9", | ||
"@nuxt/eslint-config": "^0.3.13", | ||
"@nuxt/module-builder": "^0.8.1", | ||
"@nuxt/schema": "^3.12.3", | ||
"@nuxt/test-utils": "^3.13.1", | ||
"@types/node": "^20.14.9", | ||
"changelogen": "^0.5.5", | ||
"eslint": "^9.6.0", | ||
"nuxt": "^3.12.3", | ||
"typescript": "latest", | ||
"vitest": "^1.6.0", | ||
"vue-tsc": "^2.0.24" | ||
} | ||
} |
Oops, something went wrong.