Skip to content

Commit ce26db3

Browse files
committed
Add eslint
1 parent 5fb8f7e commit ce26db3

File tree

15 files changed

+1776
-52
lines changed

15 files changed

+1776
-52
lines changed

.eslintrc.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
extends: [
3+
'artisan',
4+
],
5+
}

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default defineConfig({
5555
plugins: [
5656
nodePolyfills({
5757
// To add only specific polyfills, add them here. If no option is passed, adds all polyfills
58-
include: ['path']
58+
include: ['path'],
5959
// To exclude specific polyfills, add them to this list. Note: if include is provided, this has no effect
6060
exclude: [
6161
'http', // Excludes the polyfill for `http` and `node:http`.
@@ -80,8 +80,10 @@ export default defineConfig({
8080

8181
### All polyfills
8282

83-
- If protocolImports is true, also adds node:[module]
83+
- If protocolImports is true, also adds node:[module]
84+
8485
```js
86+
[
8587
'_stream_duplex',
8688
'_stream_passthrough',
8789
'_stream_readable',
@@ -122,4 +124,5 @@ export default defineConfig({
122124
'util',
123125
'vm',
124126
'zlib',
127+
]
125128
```

examples/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"private": true,
32
"type": "module",
3+
"private": true,
44
"scripts": {
55
"build": "vite build",
66
"dev": "vite",

examples/react/src/app.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function App() {
1919
</button>
2020
</p>
2121
<p>
22+
{/* eslint-disable-next-line n/prefer-global/buffer */}
2223
The following text is encoded and decoded with Buffer: {Buffer.from('Hello!').toString()}
2324
</p>
2425
</div>
@@ -32,6 +33,6 @@ export const app = () => {
3233
<App />
3334
<ReactQueryDevtools initialIsOpen={true} />
3435
</QueryClientProvider>
35-
</React.StrictMode>
36+
</React.StrictMode>,
3637
)
3738
}

examples/vanilla/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"private": true,
32
"type": "module",
3+
"private": true,
44
"scripts": {
55
"build": "vite build",
66
"dev": "vite",

examples/vanilla/src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
/* eslint-disable no-console */
12
import { Buffer } from 'node:buffer'
23
import { resolve } from 'node:path'
34
import * as process from 'node:process'
4-
import fs from 'fs'
5-
import { readFileSync } from 'node:fs'
5+
import fs, { readFileSync } from 'node:fs'
66
import { cloneDeep } from 'lodash-es'
77
import { fetch } from 'ohmyfetch'
88

@@ -22,7 +22,7 @@ console.log(resolve('.'))
2222
console.log(process)
2323
console.log(process.env)
2424
console.log(globalThis.Array)
25-
console.log(Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]).readBigUInt64BE(0))
25+
console.log(Buffer.from([0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF]).readBigUInt64BE(0))
2626
console.log(Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]))
2727
console.log(Array)
2828
console.log(readFileSync('./test.txt', 'utf-8'))

examples/vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"private": true,
32
"type": "module",
3+
"private": true,
44
"scripts": {
55
"build": "vite build",
66
"dev": "vite",

examples/vue/src/app.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { defineComponent, ref } from 'vue'
33
44
export default defineComponent({
55
setup() {
6+
// eslint-disable-next-line n/prefer-global/buffer
67
const msg = ref(Buffer.from(Buffer.from('Hello, friend!').toString('base64'), 'base64').toString('ascii'))
78
89
return {

package.json

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
22
"name": "vite-plugin-node-polyfills",
3-
"description": "A Vite plugin to polyfill Node's Core Modules for browser environments.",
3+
"type": "module",
44
"version": "0.16.0",
5+
"packageManager": "[email protected]",
6+
"description": "A Vite plugin to polyfill Node's Core Modules for browser environments.",
57
"author": "David Myers <[email protected]>",
8+
"license": "MIT",
69
"funding": "https://github.com/sponsors/davidmyersdev",
710
"homepage": "https://github.com/davidmyersdev/vite-plugin-node-polyfills",
8-
"license": "MIT",
911
"repository": {
1012
"type": "git",
1113
"url": "git+https://github.com/davidmyersdev/vite-plugin-node-polyfills.git"
@@ -19,15 +21,11 @@
1921
"vite",
2022
"vite-plugin"
2123
],
22-
"type": "module",
23-
"main": "./dist/index.cjs",
24-
"module": "./dist/index.js",
25-
"types": "./dist/index.d.ts",
2624
"exports": {
2725
".": {
26+
"types": "./dist/index.d.ts",
2827
"require": "./dist/index.cjs",
29-
"import": "./dist/index.js",
30-
"types": "./dist/index.d.ts"
28+
"import": "./dist/index.js"
3129
},
3230
"./shims": {
3331
"require": "./shims/dist/index.cjs",
@@ -38,6 +36,9 @@
3836
"import": "./shims/banner/dist/index.cjs"
3937
}
4038
},
39+
"main": "./dist/index.cjs",
40+
"module": "./dist/index.js",
41+
"types": "./dist/index.d.ts",
4142
"files": [
4243
"dist",
4344
"shims"
@@ -48,6 +49,8 @@
4849
"build:shims": "vite build ./shims",
4950
"build:shims:banner": "vite-node ./shims/banner/build.ts",
5051
"build:types": "run-s typecheck",
52+
"lint": "eslint .",
53+
"lint:fix": "eslint --fix .",
5154
"test": "run-s test:build",
5255
"test:build": "run-p test:build:*",
5356
"test:build:react": "pnpm -C ./examples/react run build",
@@ -62,10 +65,20 @@
6265
"typecheck:vanilla": "pnpm -C ./examples/vanilla run typecheck",
6366
"typecheck:vue": "pnpm -C ./examples/vue run typecheck"
6467
},
65-
"packageManager": "[email protected]",
68+
"peerDependencies": {
69+
"vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
70+
},
71+
"dependencies": {
72+
"@rollup/plugin-inject": "^5.0.5",
73+
"buffer-polyfill": "npm:buffer@^6.0.3",
74+
"node-stdlib-browser": "^1.2.0",
75+
"process": "^0.11.10"
76+
},
6677
"devDependencies": {
6778
"@types/node": "^18.18.8",
6879
"esbuild": "^0.18.20",
80+
"eslint": "^8.54.0",
81+
"eslint-config-artisan": "^0.2.1",
6982
"npm-run-all": "^4.1.5",
7083
"rollup": "^3.29.4",
7184
"typescript": "4.8.3",
@@ -75,15 +88,6 @@
7588
"vite-plugin-inspect": "^0.7.42",
7689
"vite-plugin-node-polyfills": "workspace:*"
7790
},
78-
"dependencies": {
79-
"@rollup/plugin-inject": "^5.0.5",
80-
"buffer-polyfill": "npm:buffer@^6.0.3",
81-
"node-stdlib-browser": "^1.2.0",
82-
"process": "^0.11.10"
83-
},
84-
"peerDependencies": {
85-
"vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
86-
},
8791
"publishConfig": {
8892
"access": "public"
8993
},

0 commit comments

Comments
 (0)