Skip to content

Commit

Permalink
Update deps (#1025)
Browse files Browse the repository at this point in the history
* update all deps

* migrate Babel config

* remove react from dev deps

* remove semver from dev deps

* update eslint to 9.6.0

* replace rimraf by native fs calls
  • Loading branch information
JLHwung authored Jul 10, 2024
1 parent 943f412 commit 06c3ad8
Show file tree
Hide file tree
Showing 14 changed files with 1,930 additions and 2,161 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

38 changes: 0 additions & 38 deletions .eslintrc

This file was deleted.

30 changes: 25 additions & 5 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
{
"assumptions": {
"arrayLikeIsIterable": true,
"constantReexports": true,
"ignoreFunctionLength": true,
"ignoreToPrimitiveHint": true,
"mutableTemplateObject": true,
"noClassCalls": true,
"noDocumentAll": true,
"objectRestNoSymbols": true,
"privateFieldsAsProperties": true,
"pureGetters": true,
"setClassMethods": true,
"setComputedProperties": true,
"setPublicClassFields": true,
"setSpreadProperties": true,
"skipForOfIteratorClosing": true,
"superIsCallableConstructor": true
},
"targets": {
"node": "14.15.0"
},
"presets": [
["@babel/preset-env", {
"loose": true,
"bugfixes": true,
"modules": false
}]
[
"@babel/preset-env",
{
"bugfixes": true,
"modules": false
}
]
]
}
51 changes: 51 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import globals from "globals";
import babelParser from "@babel/eslint-parser";
import js from "@eslint/js";

export default [
{
ignores: [
"**/lib",
"**/node_modules",
"**/scripts",
"test/output",
"test/fixtures",
],
},
js.configs.recommended,
{
languageOptions: {
globals: globals.node,
parser: babelParser,
ecmaVersion: "latest",
sourceType: "module",
},

rules: {
camelcase: "off",
"consistent-return": "off",
curly: ["error", "multi-line"],
"linebreak-style": ["error", "unix"],
"max-len": ["error", 110, 2],
"new-cap": "off",
"no-cond-assign": "off",
"no-confusing-arrow": "error",
"no-console": "off",
"no-constant-condition": "off",
"no-empty": "off",
"no-fallthrough": "off",
"no-inner-declarations": "off",
"no-labels": "off",
"no-loop-func": "off",
"no-process-exit": "off",
"no-return-assign": "off",
"no-shadow": "off",
"no-underscore-dangle": "off",
"no-unreachable": "off",
"no-use-before-define": "off",
strict: "off",
},
},
eslintPluginPrettierRecommended,
];
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,17 @@
"@babel/preset-env": "^7.23.3",
"ava": "^3.13.0",
"c8": "^8.0.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint": "^9.6.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"globals": "^15.8.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.3",
"prettier": "^3.0.0",
"react": "^17.0.1",
"rimraf": "^5.0.1",
"semver": "7.5.2",
"webpack": "^5.89.0"
},
"scripts": {
"clean": "rimraf lib/",
"clean": "node ./scripts/rimraf.mjs lib",
"build": "babel src/ --out-dir lib/ --copy-files",
"format": "prettier --write --trailing-comma all 'src/**/*.js' 'test/**/*.test.js' 'test/helpers/*.js' && prettier --write --trailing-comma es5 'scripts/*.js'",
"lint": "eslint src test",
Expand Down
5 changes: 5 additions & 0 deletions scripts/rimraf.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { rmSync } from "fs";

if (process.argv[2]) {
rmSync(process.argv[2], { recursive: true, force: true });
}
4 changes: 2 additions & 2 deletions src/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let hashType = "sha256";
// use md5 hashing if sha256 is not available
try {
crypto.createHash(hashType);
} catch (err) {
} catch {
hashType = "md5";
}

Expand Down Expand Up @@ -98,7 +98,7 @@ const handleCache = async function (directory, params) {
// No errors mean that the file was previously cached
// we just need to return it
return await read(file, cacheCompression);
} catch (err) {}
} catch {}

const fallback =
typeof cacheDirectory !== "string" && directory !== os.tmpdir();
Expand Down
11 changes: 7 additions & 4 deletions test/cache.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import test from "ava";
import fs from "fs";
import path from "path";
import { rimraf } from "rimraf";
import { webpackAsync } from "./helpers/webpackAsync.js";
import createTestDirectory from "./helpers/createTestDirectory.js";

Expand Down Expand Up @@ -40,8 +39,13 @@ test.beforeEach(async t => {
const cacheDirectory = await createTestDirectory(cacheDir, t.title);
t.context.cacheDirectory = cacheDirectory;
});
test.beforeEach(() => rimraf(defaultCacheDir));
test.afterEach(t => rimraf([t.context.directory, t.context.cacheDirectory]));
test.beforeEach(() =>
fs.rmSync(defaultCacheDir, { recursive: true, force: true }),
);
test.afterEach(t => {
fs.rmSync(t.context.directory, { recursive: true, force: true });
fs.rmSync(t.context.cacheDirectory, { recursive: true, force: true });
});

test("should output files to cache directory", async t => {
const config = Object.assign({}, globalConfig, {
Expand Down Expand Up @@ -100,7 +104,6 @@ test("should output json.gz files to standard cache dir by default", async t =>
t.true(files.length > 0);
});

// eslint-disable-next-line max-len
test("should output non-compressed files to standard cache dir when cacheCompression is set to false", async t => {
const config = Object.assign({}, globalConfig, {
output: {
Expand Down
3 changes: 1 addition & 2 deletions test/helpers/createTestDirectory.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import path from "path";
import fs from "fs/promises";
import { rimraf } from "rimraf";

export default async function createTestDirectory(baseDirectory, testTitle) {
const directory = path.join(baseDirectory, escapeDirectory(testTitle));

await rimraf(directory);
await fs.rm(directory, { recursive: true, force: true });
await fs.mkdir(directory, { recursive: true });
return directory;
}
Expand Down
5 changes: 3 additions & 2 deletions test/loader.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import test from "ava";
import fs from "fs";
import path from "path";
import { rimraf } from "rimraf";
import { satisfies } from "semver";
import createTestDirectory from "./helpers/createTestDirectory.js";
import { webpackAsync } from "./helpers/webpackAsync.js";
Expand Down Expand Up @@ -35,7 +34,9 @@ test.beforeEach(async t => {
t.context.directory = directory;
});

test.afterEach(t => rimraf(t.context.directory));
test.afterEach(t =>
fs.rmSync(t.context.directory, { recursive: true, force: true }),
);

test("should transpile the code snippet", async t => {
const config = Object.assign({}, globalConfig, {
Expand Down
6 changes: 4 additions & 2 deletions test/metadata.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from "ava";
import path from "path";
import { rimraf } from "rimraf";
import fs from "fs";
import createTestDirectory from "./helpers/createTestDirectory.js";
import { webpackAsync } from "./helpers/webpackAsync.js";
import { NormalModule } from "webpack";
Expand Down Expand Up @@ -45,7 +45,9 @@ test.beforeEach(async t => {
t.context.directory = directory;
});

test.afterEach(t => rimraf(t.context.directory));
test.afterEach(t =>
fs.rmSync(t.context.directory, { recursive: true, force: true }),
);

test("should obtain metadata from the transform result", async t => {
let actualMetadata;
Expand Down
5 changes: 3 additions & 2 deletions test/options.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import test from "ava";
import fs from "fs";
import path from "path";
import { rimraf } from "rimraf";
import { webpackAsync } from "./helpers/webpackAsync.js";
import createTestDirectory from "./helpers/createTestDirectory.js";

Expand Down Expand Up @@ -31,7 +30,9 @@ test.beforeEach(async t => {
t.context.directory = directory;
});

test.afterEach(t => rimraf(t.context.directory));
test.afterEach(t =>
fs.rmSync(t.context.directory, { recursive: true, force: true }),
);

test("should interpret options given to the loader", async t => {
const config = Object.assign({}, globalConfig, {
Expand Down
5 changes: 3 additions & 2 deletions test/sourcemaps.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import test from "ava";
import fs from "fs";
import path from "path";
import { rimraf } from "rimraf";
import { webpackAsync } from "./helpers/webpackAsync.js";
import createTestDirectory from "./helpers/createTestDirectory.js";

Expand All @@ -28,7 +27,9 @@ test.beforeEach(async t => {
t.context.directory = directory;
});

test.afterEach(t => rimraf(t.context.directory));
test.afterEach(t =>
fs.rmSync(t.context.directory, { recursive: true, force: true }),
);

test("should output webpack's sourcemap", async t => {
const config = Object.assign({}, globalConfig, {
Expand Down
Loading

0 comments on commit 06c3ad8

Please sign in to comment.