Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .eslintignore

This file was deleted.

29 changes: 0 additions & 29 deletions .eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion __tests__/importer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe("importer", () => {

it("warns about incorrect resolving", async () => {
const warning = await validateImport('@import "smh.css"', {
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-return
// eslint-disable-next-line @typescript-eslint/no-explicit-any
resolve: () => "lol" as any,
});
expect(warning).toMatchSnapshot("warning");
Expand Down
17 changes: 8 additions & 9 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/naming-convention */
import fs from "fs-extra";
import { rollup } from "rollup";
import { RawSourceMap } from "source-map-js";
Expand All @@ -25,21 +24,21 @@ validateMany("basic", [
title: "mode-fail",
shouldFail: true,
input: "simple/index.js",
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: { mode: "mash" as any },
},
{
title: "use-fail",
shouldFail: true,
input: "simple/index.js",
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: { use: [false] as any },
},
{
title: "use-type-fail",
shouldFail: true,
input: "simple/index.js",
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: { use: false as any },
},
{
Expand All @@ -64,14 +63,14 @@ validateMany("basic", [
title: "plugin-fail",
shouldFail: true,
input: "simple/index.js",
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: { plugins: ["pulverizer"] as any },
},
{
title: "plugin-type-fail",
shouldFail: true,
input: "simple/index.js",
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: { plugins: "pulverizer" as any },
},
{
Expand Down Expand Up @@ -744,9 +743,9 @@ test("augment-chunk-hash", async () => {

const [foo1, bar, foo2] = outputFiles;

const foo1Hash = foo1.split(".")[1];
const foo2Hash = foo1.split(".")[1];
const barHash = bar.split(".")[1];
const foo1Hash = foo1.split(".", 2)[1];
const foo2Hash = foo1.split(".", 2)[1];
const barHash = bar.split(".", 2)[1];

// Verify that [hash] part of the filenames is truthy
expect(foo1Hash).toBeTruthy();
Expand Down
2 changes: 1 addition & 1 deletion __tests__/setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { jest } from "@jest/globals";
export {}; // fixes "isolatedModules" warning
// fixes "isolatedModules" warning
jest.setTimeout(30_000);
2 changes: 1 addition & 1 deletion __tests__/url-resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("url resolver", () => {

it("warns about incorrect resolving", async () => {
const warning = await validateUrl(".foo{background:url(bg.png)}", {
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-return
// eslint-disable-next-line @typescript-eslint/no-explicit-any
resolve: () => "lol" as any,
});
expect(warning).toMatchSnapshot("warning");
Expand Down
4 changes: 2 additions & 2 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("less", () => {
jest.unstable_mockModule("less", () => jest.fn());
const loaders = new Loaders({ use: [["less", {}]], loaders: [], extensions: [""] });
await expect(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
loaders.process({ code: "" }, { id: "file.less" } as any),
).rejects.toThrowErrorMatchingSnapshot();
});
Expand All @@ -50,7 +50,7 @@ describe("stylus", () => {
jest.unstable_mockModule("stylus", () => jest.fn());
const loaders = new Loaders({ use: [["stylus", {}]], loaders: [], extensions: [""] });
await expect(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
loaders.process({ code: "" }, { id: "file.styl" } as any),
).rejects.toThrowErrorMatchingSnapshot();
});
Expand Down
130 changes: 130 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import importPlugin from "eslint-plugin-import-x";
import jest from "eslint-plugin-jest";
import unicorn from "eslint-plugin-unicorn";
import prettier from "eslint-config-prettier/flat";
import globals from "globals";

export default tseslint.config(
// Global ignores (replaces .eslintignore)
{
ignores: [
"dist/**",
"tmp/**",
".cache/**",
"coverage/**",
"docs/**",
"__tests__/fixtures/**",
"eslint.config.*",
"babel.config.js",
"runtime/**",
],
},

// ESLint recommended
js.configs.recommended,

// TypeScript: parser + plugin rules (recommended, no type-aware rules)
...tseslint.configs.recommended,

// Language options (replaces env + parserOptions)
{
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
...globals.node,
},
},
},

// Browser globals for runtime/inject-css.js
{
files: ["runtime/inject-css.js"],
languageOptions: {
globals: {
...globals.browser,
},
},
},

// import plugin
importPlugin.flatConfigs.recommended,
{
settings: {
"import-x/resolver": {
node: { extensions: [".mjs", ".js", ".cjs", ".json", ".ts"] },
},
},
},

// unicorn recommended
{
...unicorn.configs.recommended,
files: ["**/*.{js,ts,mjs,cjs}"],
},

// jest plugin (scoped to test files)
{
files: ["__tests__/**/*.{ts,js}"],
...jest.configs["flat/recommended"],
},

// Custom rules
{
rules: {
"no-await-in-loop": "error",
"no-var": "error",
"prefer-const": "error",
"prefer-template": "error",
"sort-vars": "error",
// Preserve old behavior: allow unused catch arguments
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "none" }],
yoda: ["error", "never", { exceptRange: true }],

// unicorn overrides
// renamed: prefer-json-parse-buffer -> consistent-json-file-read, prevent-abbreviations -> name-replacements
"unicorn/no-null": "off",
"unicorn/consistent-json-file-read": "off",
"unicorn/prefer-module": "off",
"unicorn/prefer-node-protocol": "off",
"unicorn/prefer-set-has": "off",
"unicorn/name-replacements": "off",
// new v72 rules that are too noisy for this project
"unicorn/filename-case": "off",
"unicorn/no-anonymous-default-export": "off",
"unicorn/no-array-sort": "off",
"unicorn/no-unreadable-for-of-expression": "off",
"unicorn/no-this-outside-of-class": "off",
"unicorn/no-unsafe-string-replacement": "off",
"unicorn/no-break-in-nested-loop": "off",
"unicorn/no-return-array-push": "off",
"unicorn/prefer-await": "off",
"unicorn/max-nested-calls": "off",
"unicorn/import-style": "off",
"unicorn/require-array-sort-compare": "off",
"unicorn/no-computed-property-existence-check": "off",
"unicorn/consistent-boolean-name": "off",
"unicorn/no-top-level-assignment-in-function": "off",
"unicorn/prefer-simple-condition-first": "off",
"unicorn/no-declarations-before-early-exit": "off",
"unicorn/no-array-reverse": "off",
"unicorn/prefer-code-point": "off",

// import-x: can't verify named exports from .ts files without type info
"import-x/named": "off",

// TS: allow createRequire (used for CJS interop)
"@typescript-eslint/no-require-imports": "off",
// TS: allow empty interfaces (used for type extension pattern)
"@typescript-eslint/no-empty-object-type": "off",
// TS: allow expression statements (used in test helpers)
"@typescript-eslint/no-unused-expressions": "off",
},
},

// prettier must be last
prettier,
);
Loading
Loading