Skip to content

Commit

Permalink
build: update scripts/update-lib-index.js for eslint v8
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add committed Nov 29, 2021
1 parent 4c42a2c commit e183f6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = {
"prefer-promises/dns": require("./rules/prefer-promises/dns"),
"prefer-promises/fs": require("./rules/prefer-promises/fs"),
"process-exit-as-throw": require("./rules/process-exit-as-throw"),
shebang: require("./rules/shebang"),
"shebang": require("./rules/shebang"),

// Deprecated rules.
"no-hide-core-modules": require("./rules/no-hide-core-modules"),
Expand Down
13 changes: 8 additions & 5 deletions scripts/update-lib-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

const fs = require("fs")
const path = require("path")
const { CLIEngine } = require("eslint")
const { ESLint } = require("eslint")
const { rules } = require("./rules")

const filePath = path.resolve(__dirname, "../lib/index.js")
Expand Down Expand Up @@ -35,8 +35,11 @@ module.exports = {
},
}
`
const engine = new CLIEngine({ fix: true })
const lintResult = engine.executeOnText(rawContent, filePath)
const content = lintResult.results[0].output || rawContent
const linter = new ESLint({ fix: true })

// tla is not allowed in scripts. :)
linter.lintText(rawContent, { filePath }).then(lintResult => {
const content = lintResult[0].output || rawContent
fs.writeFileSync(filePath, content)
})

fs.writeFileSync(filePath, content)

0 comments on commit e183f6e

Please sign in to comment.