Skip to content

Commit 1bfc0ce

Browse files
refactor!: add support for nuxt 3/nuxt bridge (#70)
* refactor: add support for nuxt 3/nuxt bridge * chore: update module * chore: update module * chore: update module * test: add simple test * chore: use `hookOnce` * docs: spli pnpm, yarn and npm
1 parent cd820c0 commit 1bfc0ce

22 files changed

+8064
-11873
lines changed

.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# editorconfig.org
21
root = true
32

43
[*]

.github/workflows/ci.yml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,28 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
# os: [ubuntu-latest, macos-latest, windows-latest]
1817
os: [ubuntu-latest]
19-
node: [12]
18+
node: [16]
2019

2120
steps:
21+
- uses: actions/checkout@v3
22+
- run: corepack enable
2223
- uses: actions/setup-node@v3
2324
with:
2425
node-version: ${{ matrix.node }}
26+
cache: "pnpm"
2527

26-
- name: checkout
27-
uses: actions/checkout@v3
28+
- name: 📦 Install dependencies
29+
run: pnpm install --frozen-lockfile
2830

29-
- name: cache node_modules
30-
uses: actions/cache@v3
31-
with:
32-
path: node_modules
33-
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
34-
35-
- name: Install dependencies
36-
if: steps.cache.outputs.cache-hit != 'true'
37-
run: yarn
31+
- name: 🚧 Set up project
32+
run: pnpm dev:prepare
3833

39-
- name: Lint
40-
run: yarn lint
34+
- name: 🛠 Build project
35+
run: pnpm build
4136

42-
- name: Test
43-
run: yarn test
37+
- name: 🧪 Test project
38+
run: pnpm test
4439

45-
- name: Coverage
40+
- name: 🟩 Coverage
4641
uses: codecov/codecov-action@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ coverage
99
dist
1010
sw.*
1111
.env
12+
.output

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shamefully-hoist=true

README.md

Lines changed: 72 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,59 @@
66
[![Codecov][codecov-src]][codecov-href]
77
[![License][license-src]][license-href]
88

9-
> ESLint module for Nuxt.js
9+
> ESLint module for Nuxt
1010
1111
[📖 **Release Notes**](./CHANGELOG.md)
1212

1313
## Requirements
1414

1515
You need to ensure that you have `eslint >= 7` installed:
1616

17+
With `pnpm`
18+
19+
```bash
20+
pnpm add -D eslint
21+
```
22+
23+
Or, with `yarn`
24+
1725
```bash
18-
yarn add --dev eslint # or npm install --save-dev eslint
26+
yarn add -D eslint
27+
```
28+
29+
Or, with `npm`
30+
31+
```bash
32+
npm install -D eslint
1933
```
2034

2135
## Setup
2236

2337
1. Add `@nuxtjs/eslint-module` dependency to your project
2438

39+
With `pnpm`
40+
2541
```bash
26-
yarn add --dev @nuxtjs/eslint-module # or npm install --save-dev @nuxtjs/eslint-module
42+
pnpm add @nuxtjs/eslint-module
2743
```
2844

29-
2. Add `@nuxtjs/eslint-module` to the `buildModules` section of `nuxt.config.js`
45+
Or, with `yarn`
46+
47+
```bash
48+
yarn add @nuxtjs/eslint-module
49+
```
50+
51+
Or, with `npm`
52+
53+
```bash
54+
npm install @nuxtjs/eslint-module
55+
```
56+
57+
2. Add `@nuxtjs/eslint-module` to the `modules` section of `nuxt.config.js`
3058

3159
```js
3260
export default {
33-
buildModules: [
61+
modules: [
3462
// Simple usage
3563
'@nuxtjs/eslint-module',
3664

@@ -40,13 +68,11 @@ export default {
4068
}
4169
```
4270

43-
:warning: If you are using Nuxt **< v2.9** you have to install the module as a `dependency` (No `--dev` or `--save-dev` flags) and use `modules` section in `nuxt.config.js` instead of `buildModules`.
44-
4571
### Using top level options
4672

4773
```js
4874
export default {
49-
buildModules: [
75+
modules: [
5076
'@nuxtjs/eslint-module'
5177
],
5278
eslint: {
@@ -57,11 +83,11 @@ export default {
5783

5884
## Options
5985

60-
You can pass [eslint options](https://eslint.org/docs/developer-guide/nodejs-api#-new-eslintoptions).
86+
You can pass [eslint options](https://eslint.org/docs/latest/integrate/nodejs-api#-new-eslintoptions).
6187

6288
Note that the config option you provide will be passed to the `ESLint` class.
6389
This is a different set of options than what you'd specify in `package.json` or `.eslintrc`.
64-
See the [eslint docs](https://eslint.org/docs/developer-guide/nodejs-api#-new-eslintoptions) for more details.
90+
See the [eslint docs](https://eslint.org/docs/latest/integrate/nodejs-api#-new-eslintoptions) for more details.
6591

6692
### `cache`
6793

@@ -70,129 +96,91 @@ See the [eslint docs](https://eslint.org/docs/developer-guide/nodejs-api#-new-es
7096

7197
**Note**: The cache is enabled by default to decrease execution time.
7298

73-
### `context`
74-
75-
- Type: `String`
76-
- Default: `srcDir`
77-
78-
A string indicating the root of your files.
79-
80-
### `eslintPath`
81-
82-
- Type: `String`
83-
- Default: `eslint`
84-
85-
Path to `eslint` instance that will be used for linting.
86-
8799
### `exclude`
88100

89-
- Type: `String|Array[String]`
90-
- Default: `'node_modules'`
101+
- Type: `Array[String]`
102+
- Default: `['**/node_modules/**']]`
91103

92-
Specify the files and/or directories to exclude. Must be relative to `options.context`.
104+
Specify the files and/or directories to exclude.
93105

94106
### `extensions`
95107

96108
- Type: `String|Array[String]`
97-
- Default: `['js', 'ts', 'vue']`
109+
- Default: `['js', 'jsx', 'ts', 'tsx', 'vue']`
98110

99111
Specify extensions that should be checked.
100112

101-
### `files`
113+
### `eslintPath`
102114

103-
- Type: `String|Array[String]`
104-
- Default: `null`
115+
- Type: `String`
116+
- Default: `eslint`
105117

106-
Specify directories, files, or globs. Must be relative to `options.context`.
107-
Directories are traversed recursively looking for files matching `options.extensions`.
108-
File and glob patterns ignore `options.extensions`.
118+
Path to `eslint` instance that will be used for linting.
109119

110-
### `fix`
120+
#### `emitError`
111121

112122
- Type: `Boolean`
113-
- Default: `false`
114-
115-
Will enable [ESLint autofix feature](https://eslint.org/docs/developer-guide/nodejs-api#cliengineoutputfixes).
116-
117-
**Be careful: this option will change source files.**
118-
119-
### `formatter`
123+
- Default: `true`
120124

121-
- Type: `String|Function`
122-
- Default: `'stylish'`
125+
The errors found will be printed.
123126

124-
Accepts a function that will have one argument: an array of eslint messages (object). The function must return the output as a string. You can use official [eslint formatters](https://eslint.org/docs/user-guide/formatters/).
125-
126-
### `lintDirtyModulesOnly`
127+
#### `emitWarning`
127128

128129
- Type: `Boolean`
129130
- Default: `true`
130131

131-
Lint only changed files, skip lint on start.
132-
133-
### `threads`
134-
135-
- Type: `Boolean | Number`
136-
- Default: `false`
132+
The warnings found will be printed.
137133

138-
Will run lint tasks across a thread pool. The pool size is automatic unless you specify a number.
139-
140-
### Errors and Warning
141-
142-
**By default the plugin will auto adjust error reporting depending on eslint errors/warnings counts.**
143-
You can still force this behavior by using `emitError` **or** `emitWarning` options:
144-
145-
#### `emitError`
134+
#### `failOnWarning`
146135

147136
- Type: `Boolean`
148137
- Default: `false`
149138

150-
Will always return errors, if set to `true`.
139+
Will cause the module build to fail if there are any warnings, based on `emitWarning`.
151140

152-
#### `emitWarning`
141+
#### `failOnError`
153142

154143
- Type: `Boolean`
155144
- Default: `false`
156145

157-
Will always return warnings, if set to `true`.
146+
Will cause the module build to fail if there are any errors, based on `emitError`.
158147

159-
#### `failOnError`
148+
### `fix`
160149

161150
- Type: `Boolean`
162151
- Default: `false`
163152

164-
Will cause the module build to fail if there are any errors, if set to `true`.
153+
Auto fix source code.
165154

166-
#### `failOnWarning`
155+
**Be careful: this option will change source files.**
167156

168-
- Type: `Boolean`
169-
- Default: `false`
157+
### `formatter`
170158

171-
Will cause the module build to fail if there are any warnings, if set to `true`.
159+
- Type: `String|Function`
160+
- Default: `'stylish'`
172161

173-
#### `quiet`
162+
Accepts a function that will have one argument: an array of eslint messages (object). The function must return the output as a string. You can use official [eslint formatters](https://eslint.org/docs/user-guide/formatters/).
174163

175-
- Type: `Boolean`
176-
- Default: `false`
164+
### `lintOnStart`
177165

178-
Will process and report errors only and ignore warnings, if set to `true`.
166+
- Type: `Boolean`
167+
- Default: `true`
179168

180-
#### `outputReport`
169+
Check all matching files on project startup, too slow, turn on discreetly.
181170

182-
- Type: `Boolean|Object`
183-
- Default: `false`
171+
## Contributing
184172

185-
Write the output of the errors to a file, for example a checkstyle xml file for use for reporting on Jenkins CI.
173+
You can contribute to this module online with CodeSandBox:
186174

187-
The `filePath` is an absolute path or relative to the webpack config: `output.path`.
188-
You can pass in a different `formatter` for the output file,
189-
if none is passed in the default/configured formatter will be used.
175+
[![Edit @nuxtjs/robots](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/nuxt-community/eslint-module/?fontsize=14&hidenavigation=1&theme=dark)
190176

191-
## Development
177+
Or locally:
192178

193179
1. Clone this repository
194-
2. Install dependencies using `yarn install` or `npm install`
195-
3. Start development server using `npm run dev`
180+
2. Install dependencies using `pnpm install`
181+
3. Prepare development server using `pnpm dev:prepare`
182+
4. Build module using `pnpm build`
183+
5. Launch playground using `pnpm dev`
196184

197185
## License
198186

jest.config.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

package.json

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,55 @@
11
{
22
"name": "@nuxtjs/eslint-module",
33
"version": "3.1.0",
4-
"description": "ESLint module for Nuxt.js",
4+
"description": "ESLint module for Nuxt",
55
"repository": "nuxt-community/eslint-module",
66
"license": "MIT",
77
"contributors": [
88
"Ricardo Gobbo de Souza <[email protected]>"
99
],
10-
"main": "./dist/module.js",
11-
"types": "./dist/module.d.ts",
10+
"type": "module",
11+
"sideEffects": false,
12+
"exports": {
13+
".": {
14+
"require": "./dist/module.cjs",
15+
"import": "./dist/module.mjs"
16+
}
17+
},
18+
"main": "./dist/module.cjs",
19+
"types": "./dist/types.d.ts",
1220
"files": [
1321
"dist"
1422
],
1523
"scripts": {
16-
"build": "siroc build",
17-
"dev": "nuxt dev test/fixture/basic",
18-
"lint": "eslint --ext .js,.ts,.vue .",
19-
"prepublishOnly": "yarn build",
20-
"release": "yarn test && yarn build && standard-version && git push --follow-tags && npm publish",
21-
"test": "yarn lint && yarn jest"
24+
"build": "nuxt-module-build",
25+
"dev": "nuxi dev playground",
26+
"dev:build": "nuxi build playground",
27+
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
28+
"lint": "eslint --ext .js,.ts,.vue",
29+
"prepack": "pnpm build",
30+
"release": "pnpm test && pnpm build && changelogen --release && git push --follow-tags && pnpm publish",
31+
"test": "pnpm lint && vitest run --coverage"
2232
},
2333
"dependencies": {
24-
"consola": "^2.15.3",
25-
"defu": "^6.0.0",
26-
"eslint-webpack-plugin": "^2.6.0"
34+
"@nuxt/kit": "^3.2.3",
35+
"eslint-webpack-plugin": "^4.0.0",
36+
"vite-plugin-eslint": "^1.8.1"
2737
},
2838
"devDependencies": {
29-
"@babel/preset-typescript": "latest",
39+
"@nuxt/module-builder": "latest",
3040
"@nuxt/test-utils": "latest",
31-
"@nuxt/types": "latest",
3241
"@nuxtjs/eslint-config-typescript": "latest",
33-
"@types/jest": "latest",
34-
"@types/node": "latest",
42+
"@vitest/coverage-c8": "latest",
43+
"changelogen": "latest",
3544
"eslint": "latest",
36-
"jest": "latest",
3745
"nuxt": "latest",
38-
"siroc": "latest",
39-
"standard-version": "latest"
46+
"vitest": "latest"
4047
},
4148
"peerDependencies": {
4249
"eslint": ">=7"
4350
},
4451
"publishConfig": {
4552
"access": "public"
46-
}
53+
},
54+
"packageManager": "[email protected]"
4755
}

0 commit comments

Comments
 (0)