Skip to content

Commit

Permalink
chore(style): prepare codebase for no-unused-vars (#1800)
Browse files Browse the repository at this point in the history
### Description
Oxlint will be adding
[no-unused-vars](oxc-project/oxc#4445) soon,
which will add warnings to all unused variables. This PR updates
Rolldown's `.oxlintrc.json` and cleans up some code to prevent your CI
from failing.

---------

Co-authored-by: Yunfei <i.heyunfei@gmail.com>
  • Loading branch information
DonIsaac and hyf0 authored Jul 31, 2024
1 parent 2d6763b commit cff3088
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"rules": {
"no-unused-vars": [
"warn",
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }
],
"unicorn/prefer-node-protocol": "error",
"import/namespace": [
"error",
Expand Down
3 changes: 0 additions & 3 deletions examples/par-plugin/parallel-babel-plugin/impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,19 @@ export const babelPlugin = () => {
transform(code, id) {
const ext = nodePath.extname(id)
if (ext === '.ts' || ext === '.tsx') {
let now = performance.now()
const ast = babel.parseSync(code, {
...partialConfig?.options,
filename: id,
})
if (!ast || !partialConfig || !partialConfig.options) {
throw new Error('failed to parse')
}
let diffAst = performance.now() - now
const ret = /** @type {babel.BabelFileResult} */ (
babel.transformFromAstSync(ast, code, {
...partialConfig?.options,
filename: id,
})
)
let diffTrans = performance.now() - now - diffAst
return { code: /** @type {string} */ (ret.code) }
}
},
Expand Down
1 change: 0 additions & 1 deletion examples/par-plugin/parallel-esbuild-plugin/impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const pluginAsync = () => {
name: '@rolldown/plugin-esbuild',
async transform(code, id) {
const ext = nodePath.extname(id)
const now = performance.now()
if (ext === '.ts' || ext === '.tsx') {
const ret = await esbuild.transform(code, {
platform: 'node',
Expand Down
2 changes: 1 addition & 1 deletion packages/rolldown/src/utils/normalize-output-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function normalizeOutputOptions(
? sourcemapIgnoreList
: sourcemapIgnoreList === false
? () => false
: (relativeSourcePath: string, sourcemapPath: string) =>
: (relativeSourcePath: string, _sourcemapPath: string) =>
relativeSourcePath.includes('node_modules'),
sourcemapPathTransform,
banner: getAddon(opts, 'banner'),
Expand Down
2 changes: 1 addition & 1 deletion packages/rolldown/tests/plugin/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function buildWithPlugin(plugin: Plugin) {
plugins: [plugin],
})
await build.write({})
} catch (error) {
} catch {
// Here `renderError` test will crash it, here avoid bubble it.
// console.log(error)
}
Expand Down
1 change: 0 additions & 1 deletion packages/rolldown/tests/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
RolldownOutputAsset,
} from '../../src'
import nodePath from 'node:path'
import nodeUrl from 'node:url'
import assert from 'node:assert'
import { workspaceRoot } from '@rolldown/testing'

Expand Down
3 changes: 1 addition & 2 deletions scripts/misc/gen-esbuild-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import chalk from 'chalk'
import * as dedent from 'dedent'
import { fileURLToPath } from 'node:url'
import { URL } from 'node:url'
import { warn } from 'node:console'
import * as nodeHttps from 'node:https'
import * as nodeFs from 'node:fs'
import * as fsExtra from 'fs-extra'
Expand Down Expand Up @@ -161,7 +160,7 @@ async function readTestSuiteSource(testSuiteName) {
const sourcePath = path.resolve(__dirname, testSuite.sourcePath)
try {
return fs.readFileSync(sourcePath).toString()
} catch (err1) {
} catch {
console.log(`Could not read .go source file from ${sourcePath}.`)
console.log(`Attempting to download it from ${testSuite.sourceGithubUrl}.`)
console.log('...')
Expand Down

0 comments on commit cff3088

Please sign in to comment.