Files
codeql-action/eslint.config.mjs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

213 lines
5.5 KiB
JavaScript
Raw Normal View History

2026-02-20 15:57:26 +00:00
import { fixupPluginRules } from "@eslint/compat";
2026-02-23 18:37:31 +00:00
import js from "@eslint/js";
2024-07-16 10:11:29 -07:00
import github from "eslint-plugin-github";
2026-02-20 16:29:02 +00:00
import { importX, createNodeResolver } from "eslint-plugin-import-x";
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
2024-07-16 10:11:29 -07:00
import noAsyncForeach from "eslint-plugin-no-async-foreach";
2025-11-09 10:26:36 +00:00
import jsdoc from "eslint-plugin-jsdoc";
2026-02-20 15:57:26 +00:00
import tseslint from "typescript-eslint";
2024-07-16 15:13:51 -07:00
import globals from "globals";
import path from "path";
import { fileURLToPath } from "url";
2024-07-16 10:11:29 -07:00
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
2026-02-20 15:57:26 +00:00
const githubFlatConfigs = github.getFlatConfigs();
2024-07-16 10:11:29 -07:00
2024-07-16 15:13:51 -07:00
export default [
{
ignores: [
"**/webpack.config.js",
"build/**/*",
2024-07-16 15:13:51 -07:00
"lib/**/*",
"src/testdata/**/*",
"tests/**/*",
2025-08-21 13:34:13 +01:00
"build.mjs",
2026-03-12 18:43:14 +00:00
"ava.config.mjs",
2026-03-12 18:55:03 +00:00
"ava.setup.mjs",
2024-07-16 15:13:51 -07:00
"eslint.config.mjs",
".github/**/*",
],
},
2026-02-23 18:37:31 +00:00
// eslint recommended config
js.configs.recommended,
// Type-checked rules from typescript-eslint
...tseslint.configs.recommendedTypeChecked,
2026-02-23 18:49:38 +00:00
...tseslint.configs.strict,
2026-02-23 18:37:31 +00:00
// eslint-plugin-github recommended config
2026-02-20 15:57:26 +00:00
githubFlatConfigs.recommended,
2026-02-23 18:37:31 +00:00
// eslint-plugin-github typescript config
2026-02-20 15:57:26 +00:00
...githubFlatConfigs.typescript,
2026-02-23 18:37:31 +00:00
// import-x TypeScript settings
2026-02-20 16:29:02 +00:00
// This is needed for import-x rules to properly parse TypeScript files.
{
settings: importX.flatConfigs.typescript.settings,
},
2024-07-16 15:13:51 -07:00
{
2024-07-16 10:11:29 -07:00
plugins: {
2026-02-20 16:29:02 +00:00
"import-x": importX,
2026-02-20 15:57:26 +00:00
"no-async-foreach": fixupPluginRules(noAsyncForeach),
jsdoc: jsdoc,
2024-07-16 10:11:29 -07:00
},
languageOptions: {
2026-02-20 15:57:26 +00:00
ecmaVersion: "latest",
2024-07-16 15:13:51 -07:00
sourceType: "module",
2024-07-16 10:11:29 -07:00
2024-07-16 15:13:51 -07:00
globals: {
...globals.node,
},
parserOptions: {
project: "./tsconfig.json",
},
2024-07-16 10:11:29 -07:00
},
settings: {
2024-07-16 15:13:51 -07:00
"import/resolver": {
node: {
moduleDirectory: ["node_modules", "src"],
2024-07-16 10:11:29 -07:00
},
2024-07-16 15:13:51 -07:00
typescript: {},
},
"import/ignore": [
"sinon",
"uuid",
"@octokit/plugin-retry",
"del",
"get-folder-size",
],
2026-02-20 16:29:02 +00:00
"import-x/resolver-next": [
createTypeScriptImportResolver(),
createNodeResolver({
extensions: [".ts", ".js", ".json"],
}),
],
2024-07-16 10:11:29 -07:00
},
rules: {
2026-02-20 15:57:26 +00:00
"github/filenames-match-regex": ["error", "^[a-z0-9-]+(\\.test)?$"],
2024-07-16 15:13:51 -07:00
"i18n-text/no-en": "off",
"import/extensions": [
"error",
{
json: {},
},
],
"import/no-amd": "error",
"import/no-commonjs": "error",
2026-02-20 16:29:02 +00:00
// import/no-cycle does not seem to work with ESLint 9.
// Use import-x/no-cycle from eslint-plugin-import-x instead.
"import/no-cycle": "off",
"import-x/no-cycle": "error",
2024-07-16 15:13:51 -07:00
"import/no-dynamic-require": "error",
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: true,
},
],
"import/no-namespace": "off",
"import/no-unresolved": "error",
"import/no-webpack-loader-syntax": "error",
"import/order": [
"error",
{
alphabetize: {
order: "asc",
},
"newlines-between": "always",
},
],
"max-len": [
"error",
{
code: 120,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
},
],
"no-async-foreach/no-async-foreach": "error",
"no-sequences": "error",
"no-shadow": "off",
2026-02-23 18:49:38 +00:00
// This is overly restrictive with unsetting `EnvVar`s
"@typescript-eslint/no-dynamic-delete": "off",
2024-07-16 15:13:51 -07:00
"@typescript-eslint/no-shadow": "error",
2025-10-22 16:55:06 +01:00
"@typescript-eslint/prefer-optional-chain": "error",
2024-07-16 15:13:51 -07:00
"one-var": ["error", "never"],
2025-11-09 10:26:36 +00:00
// Check param names to ensure that we don't have outdated JSDocs.
"jsdoc/check-param-names": [
"error",
{
// We don't currently require full JSDoc coverage, so this rule
// should not error on missing @param annotations.
disableMissingParamChecks: true,
},
2025-11-09 10:26:36 +00:00
],
2024-07-16 10:11:29 -07:00
},
2024-07-16 15:13:51 -07:00
},
{
files: ["**/*.ts", "**/*.js"],
2024-07-16 10:11:29 -07:00
rules: {
2024-07-16 15:13:51 -07:00
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
2025-08-05 11:13:02 +01:00
"@typescript-eslint/no-unsafe-enum-comparison": "off",
2024-07-16 15:13:51 -07:00
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "all",
argsIgnorePattern: "^_",
},
],
2024-07-16 15:13:51 -07:00
"func-style": "off",
2024-07-16 10:11:29 -07:00
},
2024-07-16 15:13:51 -07:00
},
2026-03-12 17:39:53 +00:00
{
files: ["pr-checks/**/*.ts"],
languageOptions: {
parserOptions: {
// Use the correct `tsconfig.json` for `pr-checks`.
project: "./pr-checks/tsconfig.json",
},
},
rules: {
// The scripts in `pr-checks` are expected to output to the console.
"no-console": "off",
"import/no-extraneous-dependencies": [
"error",
{ packageDir: [__dirname, path.resolve(__dirname, "pr-checks")] },
],
2026-03-12 17:39:53 +00:00
"@typescript-eslint/no-floating-promises": [
"error",
{
allowForKnownSafeCalls: [
// Avoid needing explicit `void` in front of `describe` calls in test files.
{ from: "package", name: ["describe"], package: "node:test" },
],
},
],
},
},
2024-07-16 15:13:51 -07:00
];