@jimmy.codes/eslint-config
Version:
A simple, modern ESLint config that covers most use cases.
85 lines (82 loc) • 2.41 kB
JavaScript
import { t as GLOB_ASTRO } from "./globs-uKx5b8lV.mjs";
import { n as extractOptions, t as interopDefault } from "./interop-default-CKeWA-H9.mjs";
import globals from "globals";
//#region src/configs/astro.ts
async function astroConfig(options) {
const extractedOptions = extractOptions(options);
const files = [GLOB_ASTRO];
const [tsPlugin, astroPlugin, astroParser, jsxA11yPlugin] = await Promise.all([
import("typescript-eslint"),
import("eslint-plugin-astro"),
import("astro-eslint-parser"),
interopDefault(import("eslint-plugin-jsx-a11y"))
]);
return [
{
files,
languageOptions: {
globals: {
...globals.node,
Astro: false,
Fragment: false
},
parser: astroParser,
parserOptions: {
extraFileExtensions: [".astro"],
parser: tsPlugin.parser
},
sourceType: "module"
},
name: "jimmy.codes/astro",
plugins: {
"astro": astroPlugin,
"jsx-a11y": jsxA11yPlugin
},
processor: "astro/client-side-ts",
rules: {
...jsxA11yPlugin.configs.recommended.rules,
"astro/missing-client-only-directive-value": "error",
"astro/no-conflict-set-directives": "error",
"astro/no-deprecated-astro-canonicalurl": "error",
"astro/no-deprecated-astro-fetchcontent": "error",
"astro/no-deprecated-astro-resolve": "error",
"astro/no-deprecated-getentrybyslug": "error",
"astro/no-exports-from-components": "off",
"astro/no-unsafe-inline-scripts": "error",
"astro/no-unused-define-vars-in-style": "error",
"astro/valid-compile": "error",
...extractedOptions?.overrides
}
},
{
files,
languageOptions: { parserOptions: {
program: null,
project: false,
projectService: false
} },
name: "jimmy.codes/astro/disable-type-checked",
rules: tsPlugin.configs.disableTypeChecked.rules
},
{
name: "jimmy.codes/astro/imports",
settings: { "import-x/core-modules": ["astro:content"] }
}
];
}
//#endregion
//#region src/utils/upwarn.ts
/**
* Converts all ESLint rules set to `"warn"` into `"error"`.
*
* @param rules - A partial set of ESLint rules.
*
* @returns A new rules object with all `"warn"` values changed to `"error"`.
*/
const upwarn = (rules = {}) => {
return Object.fromEntries(Object.entries(rules).map(([rule, option]) => {
return [rule, option === "warn" ? "error" : option];
}));
};
//#endregion
export { astroConfig as default, upwarn as t };