v7.0.0
This release convert almost secretlint packages to Pure ESM 馃帀
Breaking Changes
- Require Node.js 18+ #538
- package code format is ES2022
- Update Docker image based on Node.js 18 #468
- Update Exit Status #547
- Secretlint exits with the following values
0
: Linting succeeded, no errors found1
: Linting failed, errors found2
: Unexpected error occurred, fatal error- Previously, these values are not defined
- Add new "json" formatter for secretlint #45
- output format is changed from old "json" formatter
- Convert packages to Pure ESM package
- Convert
@secretlint/types
to dual package- See also Dual CommonJS/ES module packages
- You can import
@secretlint/types
from both CJS and ESM.
@secretlint/tester
is migrated to ESM, But we can load it using dynamic import from CJS@secretlint/tester
usesnode:test
instead of Mocha- Also, Support URL object in
snapshotDirectory
option.
It means that you can still write your rule in CommonJS.
You can migrate your snapshot testing code to secretlint v7 by following:
CommonJS Edition:
- import { snapshot } from "@secretlint/tester";
import path from "path";
import { creator as rule } from "../src/index";
+ import test from "node:test";
- describe("@secretlint/secretlint-rule-example", () => {
+ test("@secretlint/secretlint-rule-example", async (t) => {
+ const snapshot = (await import("@secretlint/tester")).snapshot;
- snapshot({
+ await snapshot({
defaultConfig: {
rules: [
{
id: "@secretlint/secretlint-rule-preset-canary",
rule,
rules: [],
options: {},
},
],
},
updateSnapshot: !!process.env.UPDATE_SNAPSHOT,
snapshotDirectory: path.join(__dirname, "snapshots"),
}).forEach((name, test) => {
- it(name, async function () {
+ return it(name, async (context) => {
const status = await test();
if (status === "skip") {
- this.skip();
+ context.skip();
}
});
});
});
Of course, you can write test in ESM and rule.
import test from "node:test";
import { snapshot } "@secretlint/teter";
import { creator as rule } from "../src/index.js";
test("@secretlint/secretlint-rule-example", async (t) => {
return snapshot({
defaultConfig: {
rules: [
{
id: "@secretlint/secretlint-rule-example",
rule,
options: {},
},
],
},
updateSnapshot: !!process.env.UPDATE_SNAPSHOT,
snapshotDirectory: new URL("snapshots", import.meta.url),
}).forEach((name, test) => {
return t.test(name, async (context) => {
const status = await test();
if (status === "skip") {
context.skip();
}
});
});
});
And run tests via Node.js Test runner
$ node --test test/index.test.js
# or
$ node --loader ts-node/esm --test test/index.test.ts
For more details, see https://github.com/secretlint/secretlint/blob/master/docs/secretlint-rule.md and Node.js Test runner
Change Logs
Breaking Changes
- refactor!(secretlint): convert to ESM by @azu in #529
- refactor!: Convert all rules to ESM by @azu in #535
- perf: output target is ES2022 by @azu in #538
- feat(docker): use Node.js 18 as base image by @azu in #540
- fix(secretlint): update meow and globby and exit status by @azu in #547
Bug Fixes
Documentation
Dependency Updates
- chore(deps): update yarn to v1.22.19 by @renovate in #531
- chore(deps): update dependency rollup to ^3.25.2 by @renovate in #533
- chore(deps): update yarn to v1.22.19 by @renovate in #539
- fix(core): update structured-source@4 by @azu in #544
- chore(deps): update to lerna-lite v2 by @azu in #549
Other Changes
Full Changelog: v6.2.4...7.0.0