Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency eslint-plugin-unicorn to v52 #5468

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions build-plugins/add-cli-entry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { chmod } from 'node:fs/promises';
import { resolve } from 'node:path';
import path from 'node:path';
import type { Plugin } from 'rollup';

const CLI_CHUNK = 'bin/rollup';
Expand All @@ -16,7 +16,7 @@ export default function addCliEntry(): Plugin {
},
name: 'add-cli-entry',
writeBundle({ dir }) {
return chmod(resolve(dir!, CLI_CHUNK), '755');
return chmod(path.resolve(dir!, CLI_CHUNK), '755');
}
};
}
4 changes: 2 additions & 2 deletions build-plugins/copy-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import path from 'node:path';
import type { Plugin } from 'rollup';

function copyRollupType(
Expand All @@ -10,7 +10,7 @@ function copyRollupType(
return {
async generateBundle(_options, _bundle, isWrite) {
if (isWrite) {
let source = await readFile(resolve(inputFile), 'utf8');
let source = await readFile(path.resolve(inputFile), 'utf8');
if (rollupImportPath) {
source = source.replace(rollupImportPath, './rollup');
}
Expand Down
4 changes: 2 additions & 2 deletions build-plugins/generate-license-file.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFile, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import path from 'node:path';
import type { PluginImpl } from 'rollup';
import license, { type Dependency, type Person } from 'rollup-plugin-license';

Expand Down Expand Up @@ -57,7 +57,7 @@ async function generateLicenseFile(
`${[...licenses].join(', ')}\n\n` +
`# Bundled dependencies:\n` +
dependencyLicenseTexts;
const licenseFile = join(directory, 'LICENSE.md');
const licenseFile = path.join(directory, 'LICENSE.md');
const existingLicenseText = await readFile(licenseFile, 'utf8');
if (existingLicenseText !== licenseText) {
await writeFile(licenseFile, licenseText);
Expand Down
4 changes: 2 additions & 2 deletions build-plugins/replace-browser-modules.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dirname, join } from 'node:path';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import type { Plugin as RollupPlugin } from 'rollup';
import type { Plugin } from 'vite';
Expand Down Expand Up @@ -37,7 +37,7 @@ export default function replaceBrowserModules(): Plugin & RollupPlugin {
name: 'replace-browser-modules',
resolveId(source: string, importer: string | undefined) {
if (importer && source[0] === '.') {
return resolutions.get(join(dirname(importer), source));
return resolutions.get(path.join(path.dirname(importer), source));
}
},
transformIndexHtml(html) {
Expand Down
6 changes: 3 additions & 3 deletions cli/run/commandPlugins.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'node:path';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import type { InputOptionsWithPlugins } from '../../src/rollup/types';
import { normalizePluginOption } from '../../src/utils/options/options';
Expand Down Expand Up @@ -73,11 +73,11 @@
}
if (!plugin) {
try {
if (pluginText[0] == '.') pluginText = resolve(pluginText);
if (pluginText[0] == '.') pluginText = path.resolve(pluginText);
// Windows absolute paths must be specified as file:// protocol URL
// Note that we do not have coverage for Windows-only code paths
else if (/^[A-Za-z]:\\/.test(pluginText)) {
pluginText = pathToFileURL(resolve(pluginText)).href;
pluginText = pathToFileURL(path.resolve(pluginText)).href;

Check warning on line 80 in cli/run/commandPlugins.ts

View check run for this annotation

Codecov / codecov/patch

cli/run/commandPlugins.ts#L80

Added line #L80 was not covered by tests
}
plugin = await requireOrImport(pluginText);
} catch (error: any) {
Expand Down
6 changes: 3 additions & 3 deletions cli/run/getConfigPath.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readdir } from 'node:fs/promises';
import { resolve } from 'node:path';
import path from 'node:path';
import { cwd } from 'node:process';
import { logMissingExternalConfig } from '../../src/utils/logs';
import { handleError } from '../logging';
Expand All @@ -8,7 +8,7 @@ const DEFAULT_CONFIG_BASE = 'rollup.config';

export async function getConfigPath(commandConfig: string | true): Promise<string> {
if (commandConfig === true) {
return resolve(await findConfigFileNameInCwd());
return path.resolve(await findConfigFileNameInCwd());
}
if (commandConfig.slice(0, 5) === 'node:') {
const packageName = commandConfig.slice(5);
Expand All @@ -27,7 +27,7 @@ export async function getConfigPath(commandConfig: string | true): Promise<strin
}
}
}
return resolve(commandConfig);
return path.resolve(commandConfig);
}

async function findConfigFileNameInCwd(): Promise<string> {
Expand Down
9 changes: 6 additions & 3 deletions cli/run/loadConfigFile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { unlink, writeFile } from 'node:fs/promises';
import { dirname, isAbsolute, join } from 'node:path';
import path from 'node:path';
import process from 'node:process';
import { pathToFileURL } from 'node:url';
import * as rollup from '../../src/node-entry';
Expand Down Expand Up @@ -98,7 +98,7 @@ async function loadTranspiledConfigFile(
const warnings = batchWarnings(commandOptions);
const inputOptions = {
external: (id: string) =>
(id[0] !== '.' && !isAbsolute(id)) || id.slice(-5, id.length) === '.json',
(id[0] !== '.' && !path.isAbsolute(id)) || id.slice(-5, id.length) === '.json',
input: fileName,
onwarn: warnings.add,
plugins: [],
Expand Down Expand Up @@ -130,7 +130,10 @@ async function loadTranspiledConfigFile(
warnings.flush();
}
return loadConfigFromWrittenFile(
join(dirname(fileName), `rollup.config-${Date.now()}.${bundleConfigAsCjs ? 'cjs' : 'mjs'}`),
path.join(
path.dirname(fileName),
`rollup.config-${Date.now()}.${bundleConfigAsCjs ? 'cjs' : 'mjs'}`
),
code
);
}
Expand Down
4 changes: 2 additions & 2 deletions docs/plugin-development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Instead of a function, hooks can also be objects. In that case, the actual hook
This can be useful when you need to run several command line tools in different [`writeBundle`](#writebundle) hooks that depend on each other (note that if possible, it is recommended to add/remove files in the sequential [`generateBundle`](#generatebundle) hook, though, which is faster, works with pure in-memory builds and permits other in-memory build plugins to see the files). You can combine this option with `order` for additional sorting.

```js twoslash
import { resolve } from 'node:path';
import path from 'node:path';
import { readdir } from 'node:fs/promises';

// ---cut-start---
Expand All @@ -137,7 +137,7 @@ Instead of a function, hooks can also be objects. In that case, the actual hook
sequential: true,
order: 'post',
async handler({ dir }) {
const topLevelFiles = await readdir(resolve(dir));
const topLevelFiles = await readdir(path.resolve(dir));
console.log(topLevelFiles);
}
}
Expand Down
5 changes: 5 additions & 0 deletions docs/repl/examples/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"unicorn/no-anonymous-default-export": "off"
}
}
4 changes: 2 additions & 2 deletions native.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { existsSync } = require('node:fs');
const { join } = require('node:path');
const path = require('node:path');
const { platform, arch, report } = require('node:process');

const isMusl = () => !report.getReport().header.glibcVersionRuntime;
Expand Down Expand Up @@ -66,7 +66,7 @@ const requireWithFriendlyError = id => {
};

const { parse, parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } = requireWithFriendlyError(
existsSync(join(__dirname, localName)) ? localName : `@rollup/rollup-${packageBase}`
existsSync(path.join(__dirname, localName)) ? localName : `@rollup/rollup-${packageBase}`
);

function getPackageBase() {
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unicorn": "^51.0.1",
"eslint-plugin-unicorn": "^52.0.0",
"eslint-plugin-vue": "^9.24.1",
"fixturify": "^3.0.0",
"flru": "^1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const nodePlugins: readonly Plugin[] = [
externalNativeImport()
];

export default async function (
export default async function getConfig(
command: Record<string, unknown>
): Promise<RollupOptions | RollupOptions[]> {
const { collectLicenses, writeLicense } = getLicenseHandler(
Expand Down
4 changes: 2 additions & 2 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { spawn } from 'node:child_process';
import { readFile } from 'node:fs/promises';
import { relative } from 'node:path';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { ESLint } from 'eslint';
import { blue, bold, cyan, green, magenta, red, yellow } from './colors.js';
Expand Down Expand Up @@ -119,6 +119,6 @@ export function toScreamingSnakeCase(string) {
* @returns {string}
*/
export function generateNotEditFilesComment(filePath) {
return `// This file is generated by ${relative(process.cwd(), fileURLToPath(filePath))}.
return `// This file is generated by ${path.relative(process.cwd(), fileURLToPath(filePath))}.
// Do not edit this file directly.\n\n`;
}
4 changes: 2 additions & 2 deletions scripts/prepublish.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import { readFile, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import path from 'node:path';
import { chdir } from 'node:process';
import { fileURLToPath } from 'node:url';
import { readJson, runWithEcho } from './helpers.js';
Expand All @@ -23,7 +23,7 @@ if (!matched) {
const isPreRelease = !!matched[1];
await verifyChangelog(isPreRelease);

await runWithEcho('npm', ['publish'], { cwd: resolve('browser') });
await runWithEcho('npm', ['publish'], { cwd: path.resolve('browser') });
await publishWasmNodePackage();

const { optionalDependencies } = await readJson(MAIN_PACKAGE);
Expand Down
6 changes: 3 additions & 3 deletions scripts/publish-wasm-node-package.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cp, mkdir, readFile, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { readJson, runWithEcho } from './helpers.js';
import { MAIN_PACKAGE } from './release-constants.js';
Expand All @@ -16,7 +16,7 @@ const PACKAGE_DIR = fileURLToPath(new URL('../wasm-node-package', import.meta.ur
* @return {string}
*/
function getOutputPath(...pathSegments) {
return resolve(PACKAGE_DIR, ...pathSegments);
return path.resolve(PACKAGE_DIR, ...pathSegments);
}

export default async function publishWasmNodePackage() {
Expand Down Expand Up @@ -51,5 +51,5 @@ export default async function publishWasmNodePackage() {
})
]);

await runWithEcho('npm', ['publish'], { cwd: resolve(PACKAGE_DIR) });
await runWithEcho('npm', ['publish'], { cwd: path.resolve(PACKAGE_DIR) });
}
26 changes: 13 additions & 13 deletions scripts/update-snapshots.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
#!/usr/bin/env node

import { readdirSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import fs from 'fs-extra';

const basePath = resolve(dirname(fileURLToPath(import.meta.url)), '../test');
const basePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../test');

const formPath = join(basePath, 'form/samples');
const formPath = path.join(basePath, 'form/samples');
const formDirectoriesToHandle = readdirSync(formPath);
for (const directory of formDirectoriesToHandle) {
const testPath = join(formPath, directory);
const testPath = path.join(formPath, directory);
const testFiles = readdirSync(testPath);
if (!testFiles.includes('_config.js')) {
formDirectoriesToHandle.push(...testFiles.map(filename => join(directory, filename)));
formDirectoriesToHandle.push(...testFiles.map(filename => path.join(directory, filename)));
} else if (testFiles.includes('_actual')) {
const expectedPath = join(testPath, '_expected');
const expectedPath = path.join(testPath, '_expected');
fs.removeSync(expectedPath);
fs.copySync(join(testPath, '_actual'), expectedPath);
fs.copySync(path.join(testPath, '_actual'), expectedPath);
} else if (testFiles.includes('_actual.js')) {
fs.copySync(join(testPath, '_actual.js'), join(testPath, '_expected.js'));
fs.copySync(path.join(testPath, '_actual.js'), path.join(testPath, '_expected.js'));
} else {
throw new Error(`Could not find test output in ${testPath}`);
}
}

const chunkingPath = join(basePath, 'chunking-form/samples');
const chunkingPath = path.join(basePath, 'chunking-form/samples');
const chunkingDirectoriesToHandle = readdirSync(chunkingPath);
for (const directory of chunkingDirectoriesToHandle) {
const testPath = join(chunkingPath, directory);
const testPath = path.join(chunkingPath, directory);
const testFiles = readdirSync(testPath);
if (!testFiles.includes('_config.js')) {
chunkingDirectoriesToHandle.push(...testFiles.map(filename => join(directory, filename)));
chunkingDirectoriesToHandle.push(...testFiles.map(filename => path.join(directory, filename)));
} else if (testFiles.includes('_actual')) {
const expectedPath = join(testPath, '_expected');
const expectedPath = path.join(testPath, '_expected');
fs.removeSync(expectedPath);
fs.copySync(join(testPath, '_actual'), expectedPath);
fs.copySync(path.join(testPath, '_actual'), expectedPath);
} else {
throw new Error(`Could not find test output in ${testPath}`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/watch/watch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'node:path';
import path from 'node:path';
import process from 'node:process';
import { createFilter } from '@rollup/pluginutils';
import { rollupInternal } from '../rollup/rollup';
Expand Down Expand Up @@ -153,7 +153,7 @@ export class Task {
this.skipWrite = Boolean(options.watch && options.watch.skipWrite);
this.outputs = this.options.output;
this.outputFiles = this.outputs.map(output => {
if (output.file || output.dir) return resolve(output.file || output.dir!);
if (output.file || output.dir) return path.resolve(output.file || output.dir!);
return undefined as never;
});

Expand Down
10 changes: 5 additions & 5 deletions test/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// globally accessible same as in the browser. this can be removed once `performance` is
// available globally in all supported platforms. [currently global for node.js v16+].
const { readFile } = require('node:fs/promises');
const { basename, resolve } = require('node:path');
const path = require('node:path');

global.performance = require('node:perf_hooks').performance;

Expand All @@ -18,13 +18,13 @@ const { assertFilesAreEqual, runTestSuiteWithSamples, compareError } = require('

runTestSuiteWithSamples(
'browser',
resolve(__dirname, 'samples'),
path.resolve(__dirname, 'samples'),
/**
* @param {import('../types').TestConfigBrowser} config
*/
(directory, config) => {
(config.skip ? it.skip : config.solo ? it.only : it)(
basename(directory) + ': ' + config.description,
path.basename(directory) + ': ' + config.description,
async () => {
let bundle;
try {
Expand Down Expand Up @@ -91,7 +91,7 @@ function assertOutputMatches(output, directory) {
}
currentDirectory[fileName] = file.source || file.code;
}
fixturify.writeSync(resolve(directory, '_actual'), actual);
const expected = fixturify.readSync(resolve(directory, '_expected'));
fixturify.writeSync(path.resolve(directory, '_actual'), actual);
const expected = fixturify.readSync(path.resolve(directory, '_expected'));
assertFilesAreEqual(actual, expected);
}