Skip to content

Commit

Permalink
flat wip
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Jun 1, 2024
1 parent 5913a05 commit 157befd
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 20 deletions.
19 changes: 8 additions & 11 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import comments from "@eslint-community/eslint-plugin-eslint-comments";
import js from "@stylistic/eslint-plugin-js";
import stylisticJs from "@stylistic/eslint-plugin-js";
import arrayFunc from "eslint-plugin-array-func";
import i from "eslint-plugin-i";
import importPlugin from "eslint-plugin-i";
import noUseExtendNative from "eslint-plugin-no-use-extend-native";
import * as regexp from "eslint-plugin-regexp";
import * as sonarjs from "eslint-plugin-sonarjs";
Expand All @@ -11,10 +11,11 @@ import globals from "globals";
import {deepMerge} from "deepie-merge";
import vitestGlobalsPlugin from "eslint-plugin-vitest-globals";
import eslintrc from "./eslintrc.js";
import type {Linter} from "eslint";

const vitestGlobals = vitestGlobalsPlugin.environments.env.globals;

const common = {
const common: Linter.FlatConfig = {
ignores: [
"**/vendor/**",
"**/*.snap",
Expand All @@ -33,23 +34,22 @@ const common = {
},
plugins: {
comments,
js,
stylisticJs,
arrayFunc,
i,
importPlugin,
noUseExtendNative,
regexp,
sonarjs,
unicorn,
vitest,
vitestGlobals,
globals,
},
settings: {
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
},
};

const confs = [];
const confs: Linter.FlatConfig[] = [];
for (const {files, rules} of eslintrc.overrides) {
const conf = deepMerge(common, {files, rules});

Expand All @@ -64,9 +64,6 @@ for (const {files, rules} of eslintrc.overrides) {
confs.push(conf);
}

// const baseDirectory = dirname(fileURLToPath(import.meta.url));
// export default (new FlatCompat({baseDirectory})).extends("eslint-config-silverwind");

export default [
deepMerge(common, {
files: [
Expand All @@ -78,4 +75,4 @@ export default [
rules: eslintrc.rules,
}),
...confs,
];
] as Linter.FlatConfig;
34 changes: 27 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
},
"devDependencies": {
"@types/eslint": "8.56.10",
"@types/js-yaml": "4.0.9",
"@types/node": "20.13.0",
"eslint": "8.57.0",
"eslint-config-silverwind-typescript": "3.2.8",
"typescript": "5.4.5",
"typescript-config-silverwind": "5.0.0",
"typescript-eslint": "7.11.0",
"updates": "16.2.0",
"versions": "12.1.2",
"vite": "5.2.12",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"**/dist/**",
],
"compilerOptions": {
"strict": true,
"types": [
"jest-extended",
"vite/client",
"vitest/globals",
"./types.d.ts",
],
},
}
7 changes: 7 additions & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type {ESLint} from "eslint";
declare module "@eslint-community/eslint-plugin-eslint-comments" { export = ESLint.Plugin; }
declare module "eslint-plugin-array-func" { export = ESLint.Plugin; }
declare module "eslint-plugin-i" { export = ESLint.Plugin; }
declare module "eslint-plugin-no-use-extend-native" { export = ESLint.Plugin; }
declare module "eslint-plugin-unicorn" { export = ESLint.Plugin; }
declare module "eslint-plugin-vitest-globals" { export = ESLint.Plugin; }

0 comments on commit 157befd

Please sign in to comment.