diff --git a/examples/eslint/bud.config.cjs b/examples/eslint/bud.config.cjs
index 92667861a7..a31ef21767 100644
--- a/examples/eslint/bud.config.cjs
+++ b/examples/eslint/bud.config.cjs
@@ -1 +1,6 @@
-module.exports = async bud => bud.template().entry('app', 'app.js')
+module.exports = async bud => {
+ bud
+ .html()
+ .entry('app', 'app.js')
+ .eslint.set(`fix`, true)
+}
diff --git a/examples/eslint/src/app.js b/examples/eslint/src/app.js
index 42892324b4..86c149f213 100644
--- a/examples/eslint/src/app.js
+++ b/examples/eslint/src/app.js
@@ -1,6 +1,6 @@
const target = document.querySelector('body')
target.innerHTML = `
-
Hello from esbuild!
+ Hello
`
diff --git a/sources/@roots/bud-eslint/package.json b/sources/@roots/bud-eslint/package.json
index 0a87495f89..20f4af14ed 100644
--- a/sources/@roots/bud-eslint/package.json
+++ b/sources/@roots/bud-eslint/package.json
@@ -29,7 +29,6 @@
},
"keywords": [
"bud",
- "bud-extension",
"eslint"
],
"engines": {
@@ -41,11 +40,15 @@
"src"
],
"type": "module",
- "module": "./lib/index.js",
- "types": "./lib/index.d.ts",
"exports": {
- ".": "./lib/index.js",
- "./extension": "./lib/extension.js"
+ ".": {
+ "types": "./lib/index.d.ts",
+ "default": "./lib/index.js"
+ },
+ "./extension": {
+ "types": "./lib/extension.d.ts",
+ "default": "./lib/extension.js"
+ }
},
"typesVersions": {
"*": {
@@ -57,6 +60,8 @@
]
}
},
+ "module": "./lib/index.js",
+ "types": "./lib/index.d.ts",
"devDependencies": {
"@roots/bud": "workspace:sources/@roots/bud",
"@skypack/package-check": "0.2.2",
@@ -72,7 +77,8 @@
},
"peerDependencies": {
"@roots/bud": "*",
- "eslint": "*"
+ "eslint": "*",
+ "eslint-webpack-plugin": "*"
},
"peerDependenciesMeta": {
"@roots/bud": {
@@ -80,6 +86,9 @@
},
"eslint": {
"optional": true
+ },
+ "eslint-webpack-plugin": {
+ "optional": true
}
},
"volta": {
diff --git a/sources/@roots/bud-eslint/src/bud/commands/bud.eslint.command.tsx b/sources/@roots/bud-eslint/src/bud/commands/bud.eslint.command.tsx
index 3c637d32de..23572068db 100644
--- a/sources/@roots/bud-eslint/src/bud/commands/bud.eslint.command.tsx
+++ b/sources/@roots/bud-eslint/src/bud/commands/bud.eslint.command.tsx
@@ -27,7 +27,7 @@ export class BudEslintCommand extends BudCommand {
)
if (!this.options?.length)
- this.options = [this.bud.path(`@src`, `**/*.{ts,tsx,js,jsx}`)]
+ this.options = [this.bud.path(`@src`, `**`, `*.{ts,tsx,js,jsx}`)]
await this.$(this.bin, [eslint, ...this.options])
}
diff --git a/sources/@roots/bud-eslint/src/extension.ts b/sources/@roots/bud-eslint/src/extension.ts
index b38059b35a..5603c4d810 100644
--- a/sources/@roots/bud-eslint/src/extension.ts
+++ b/sources/@roots/bud-eslint/src/extension.ts
@@ -11,12 +11,6 @@ import EslintPlugin from 'eslint-webpack-plugin'
/**
* Eslint webpack plugin adapter
- *
- * @public
- * @decorator `@label`
- * @decorator `@expose`
- * @decorator `@plugin`
- * @decorator `@options`
*/
@label(`@roots/bud-eslint`)
@expose(`eslint`)
@@ -29,17 +23,13 @@ import EslintPlugin from 'eslint-webpack-plugin'
resolvePluginsRelativeTo: app => app.context.basedir,
threads: false,
})
-export default class BudEslint extends Extension {
+export class BudEslint extends Extension {
/**
* `register` callback
- *
- * @public
- * @decorator `@bind`
*/
@bind
public override async register(bud: Bud) {
- const eslintPath = await this.resolve(`eslint`)
- this.setOption(`eslintPath`, eslintPath)
+ this.set(`eslintPath`, await this.resolve(`eslint`))
const findFlatConfig = ({name}) => name.includes(`eslint.config`)
@@ -47,18 +37,17 @@ export default class BudEslint extends Extension {
if (!userConfigs.some(findFlatConfig)) return
const flatConfig = userConfigs.find(findFlatConfig)
- this.setOption(`baseConfig`, flatConfig.module)
+ this.set(`baseConfig`, flatConfig.module)
}
/**
* auto-fix rule violations
*
- * @public
- * @decorator `@bind`
+ * @deprecated - Use `bud.eslint.set('fix', true)` instead.
*/
@bind
public fix(fix: boolean = true): this {
- this.setOption(`fix`, fix)
+ this.set(`fix`, fix)
return this
}
}
diff --git a/sources/@roots/bud-eslint/src/index.ts b/sources/@roots/bud-eslint/src/index.ts
index d4f1280e50..c3e411ea9d 100644
--- a/sources/@roots/bud-eslint/src/index.ts
+++ b/sources/@roots/bud-eslint/src/index.ts
@@ -12,5 +12,5 @@
import './types.js'
-import BudEslint from './extension.js'
+import {BudEslint} from './extension.js'
export default BudEslint
diff --git a/sources/@roots/bud-eslint/src/types.ts b/sources/@roots/bud-eslint/src/types.ts
index cb46851cf3..5908cff614 100644
--- a/sources/@roots/bud-eslint/src/types.ts
+++ b/sources/@roots/bud-eslint/src/types.ts
@@ -1,10 +1,14 @@
///
-import type BudEslint from './extension.js'
+import type {BudEslint} from './extension.js'
declare module '@roots/bud-framework' {
interface Bud {
- eslint: BudEslint
+ eslint: {
+ enable: BudEslint[`enable`]
+ get: BudEslint[`get`]
+ set: BudEslint[`set`]
+ }
}
interface Modules {
diff --git a/yarn.lock b/yarn.lock
index 3dab9620e0..0bff574c0e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -7266,11 +7266,14 @@ __metadata:
peerDependencies:
"@roots/bud": "*"
eslint: "*"
+ eslint-webpack-plugin: "*"
peerDependenciesMeta:
"@roots/bud":
optional: true
eslint:
optional: true
+ eslint-webpack-plugin:
+ optional: true
languageName: unknown
linkType: soft