|
1 | | -# winjs-plugin-example |
| 1 | +# @winner-fed/plugin-check-syntax |
2 | 2 |
|
3 | | -Example plugin for WinJS. |
| 3 | +WinJS plugin for checking ECMAScript syntax compatibility using `@winner-fed/unplugin-check-syntax`. |
4 | 4 |
|
5 | 5 | <p> |
6 | | - <a href="https://npmjs.com/package/winjs-plugin-example"> |
7 | | - <img src="https://img.shields.io/npm/v/winjs-plugin-example?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" /> |
| 6 | + <a href="https://npmjs.com/package/@winner-fed/plugin-check-syntax"> |
| 7 | + <img src="https://img.shields.io/npm/v/@winner-fed/plugin-check-syntax?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" /> |
8 | 8 | </a> |
9 | 9 | <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" /> |
10 | | - <a href="https://npmcharts.com/compare/winjs-plugin-example?minimal=true"><img src="https://img.shields.io/npm/dm/winjs-plugin-example.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a> |
| 10 | + <a href="https://npmcharts.com/compare/@winner-fed/plugin-check-syntax?minimal=true"><img src="https://img.shields.io/npm/dm/@winner-fed/plugin-check-syntax.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a> |
11 | 11 | </p> |
12 | 12 |
|
13 | | -## Usage |
| 13 | +## 功能特性 |
14 | 14 |
|
15 | | -Install: |
| 15 | +- 🔍 检查 ECMAScript 语法兼容性 |
| 16 | +- 🎯 支持自定义目标浏览器范围 |
| 17 | +- 📦 支持 Vite、Webpack、Rspack 构建工具 |
| 18 | +- ⚙️ 灵活的配置选项 |
| 19 | +- 🚫 支持排除特定文件 |
| 20 | + |
| 21 | +## 安装 |
16 | 22 |
|
17 | 23 | ```bash |
18 | | -npm add winjs-plugin-example -D |
| 24 | +npm add @winner-fed/plugin-check-syntax -D |
19 | 25 | ``` |
20 | 26 |
|
21 | | -Add plugin to your `.winrc.ts`: |
| 27 | +## 使用方法 |
| 28 | + |
| 29 | +在 `.winrc.ts` 配置文件中添加插件: |
22 | 30 |
|
23 | 31 | ```ts |
24 | 32 | // .winrc.ts |
25 | 33 | export default { |
26 | | - plugins: ['winjs-plugin-example'], |
27 | | - // 开启配置 |
28 | | - example: {} |
| 34 | + plugins: ['@winner-fed/plugin-check-syntax'], |
| 35 | + // 启用语法检查 |
| 36 | + checkSyntax: { |
| 37 | + // 目标浏览器范围 |
| 38 | + targets: ['> 1%', 'last 2 versions'], |
| 39 | + |
| 40 | + // 排除文件 |
| 41 | + exclude: ['node_modules', '\\.min\\.js$'], |
| 42 | + |
| 43 | + // ECMAScript 版本 |
| 44 | + ecmaVersion: 2018 |
| 45 | + } |
29 | 46 | }; |
30 | 47 | ``` |
31 | 48 |
|
32 | | -## Options |
| 49 | +## 配置选项 |
| 50 | + |
| 51 | +### targets |
| 52 | + |
| 53 | +指定项目的目标浏览器范围,值为标准的 browserslist 数组。 |
| 54 | + |
| 55 | +- 类型: `string[]` |
| 56 | +- 默认值: `undefined` |
| 57 | +- 示例: |
| 58 | + |
| 59 | +```js |
| 60 | +export default { |
| 61 | + plugins: ['@winner-fed/plugin-check-syntax'], |
| 62 | + checkSyntax: { |
| 63 | + targets: ['> 1%', 'last 2 versions', 'not ie <= 8'] |
| 64 | + } |
| 65 | +}; |
| 66 | +``` |
| 67 | + |
| 68 | +### exclude |
| 69 | + |
| 70 | +用于在检测期间排除部分源文件。可以传入一个或多个正则表达式来匹配源文件的路径。 |
| 71 | + |
| 72 | +- 类型: `string | string[]` |
| 73 | +- 默认值: `undefined` |
| 74 | +- 示例: |
33 | 75 |
|
34 | | -### foo |
| 76 | +```js |
| 77 | +export default { |
| 78 | + plugins: ['@winner-fed/plugin-check-syntax'], |
| 79 | + checkSyntax: { |
| 80 | + exclude: [ |
| 81 | + 'node_modules', |
| 82 | + '\\.min\\.js$', |
| 83 | + 'vendor/' |
| 84 | + ] |
| 85 | + } |
| 86 | +}; |
| 87 | +``` |
| 88 | + |
| 89 | +### ecmaVersion |
35 | 90 |
|
36 | | -Some description. |
| 91 | +指定构建产物中可以使用的最低 ECMAScript 语法版本。`ecmaVersion` 的优先级高于 `targets`。 |
37 | 92 |
|
38 | | -- Type: `string` |
39 | | -- Default: `undefined` |
40 | | -- Example: |
| 93 | +- 类型: `3 | 5 | 6 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 'latest'` |
| 94 | +- 默认值: `undefined` |
| 95 | +- 示例: |
41 | 96 |
|
42 | 97 | ```js |
43 | 98 | export default { |
44 | | - plugins: ['winjs-plugin-example'], |
45 | | - // 开启配置 |
46 | | - example: { |
47 | | - foo: 'bar' |
| 99 | + plugins: ['@winner-fed/plugin-check-syntax'], |
| 100 | + checkSyntax: { |
| 101 | + ecmaVersion: 2018 |
48 | 102 | } |
49 | 103 | }; |
50 | 104 | ``` |
51 | 105 |
|
| 106 | +## 简单配置 |
| 107 | + |
| 108 | +如果你只想启用默认的语法检查,可以直接设置为 `true`: |
| 109 | + |
| 110 | +```ts |
| 111 | +export default { |
| 112 | + plugins: ['@winner-fed/plugin-check-syntax'], |
| 113 | + checkSyntax: true |
| 114 | +}; |
| 115 | +``` |
| 116 | + |
| 117 | +## 支持的构建工具 |
| 118 | + |
| 119 | +- ✅ Vite |
| 120 | +- ✅ Webpack |
| 121 | +- ✅ Rspack |
| 122 | + |
52 | 123 | ## License |
53 | 124 |
|
54 | 125 | [MIT](./LICENSE). |
0 commit comments