1- // ts-check
2-
31import eslintJs from "@eslint/js" ;
42import eslintReact from "@eslint-react/eslint-plugin" ;
3+ import eslintMarkdown from "@eslint/markdown" ;
54import eslintPluginMdx from "eslint-plugin-mdx" ;
65import eslintPluginNext from "@next/eslint-plugin-next" ;
76import eslintPluginReactHooks from "eslint-plugin-react-hooks" ;
7+ import eslintPluginReactRefresh from "eslint-plugin-react-refresh" ;
88import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort" ;
99import tseslint from "typescript-eslint" ;
1010import gitignore from "eslint-config-flat-gitignore" ;
1111
12- const GLOB_TS = [ "**/*.{ts,tsx}" ] ;
13- const GLOB_JS = [ "**/*.{js,cjs,mjs}" ] ;
12+ import TSCONFIG from "./tsconfig.json" with { type : "json" } ;
13+
14+ const GLOB_TS = [ "**/*.ts" , "**/*.tsx" ] ;
15+ const GLOB_JS = [ "**/*.js" , "**/*.jsx" ] ;
16+ const GLOB_MD = [ "**/*.md" ] ;
1417const GLOB_MDX = [ "**/*.mdx" ] ;
1518const GLOB_APP = [ "app/**/*.{js,ts,jsx,tsx}" ] ;
16- const GLOB_CONFIG = [ "**/*.config.{js,mjs,cjs, ts,tsx}" ] ;
19+ const GLOB_CONFIG = [ "**/*.config.{js,mjs,ts,tsx}" ] ;
1720
1821export default tseslint . config (
19- eslintJs . configs . recommended ,
22+ {
23+ files : GLOB_MD ,
24+ extends : [
25+ eslintMarkdown . configs . recommended ,
26+ ] ,
27+ language : "markdown/gfm" ,
28+ rules : {
29+ "markdown/no-html" : "error" ,
30+ "markdown/no-missing-label-refs" : "off" ,
31+ } ,
32+ } ,
2033 {
2134 ...eslintPluginMdx . flat ,
2235 files : GLOB_MDX ,
@@ -26,30 +39,47 @@ export default tseslint.config(
2639 } ,
2740 {
2841 files : GLOB_TS ,
42+ extends : [
43+ eslintJs . configs . recommended ,
44+ tseslint . configs . recommended ,
45+ ] ,
46+ } ,
47+ {
48+ files : TSCONFIG . include ,
2949 extends : [
3050 tseslint . configs . recommendedTypeChecked ,
3151 ] ,
3252 languageOptions : {
3353 parser : tseslint . parser ,
3454 parserOptions : {
3555 project : "./tsconfig.json" ,
56+ projectService : true ,
3657 tsconfigRootDir : import . meta. dirname ,
3758 } ,
3859 } ,
3960 } ,
4061 {
41- files : [ ... GLOB_TS , ... GLOB_MDX ] ,
42- ...eslintReact . configs . recommended ,
62+ files : TSCONFIG . include ,
63+ ...eslintReact . configs [ " recommended-type-checked" ] ,
4364 } ,
4465 {
45- files : GLOB_TS ,
66+ files : TSCONFIG . include ,
4667 plugins : {
4768 "react-hooks" : eslintPluginReactHooks ,
4869 } ,
4970 rules : eslintPluginReactHooks . configs . recommended . rules ,
5071 } ,
5172 {
52- files : GLOB_TS ,
73+ files : TSCONFIG . include ,
74+ plugins : {
75+ "react-refresh" : eslintPluginReactRefresh ,
76+ } ,
77+ rules : {
78+ "react-refresh/only-export-components" : "warn" ,
79+ } ,
80+ } ,
81+ {
82+ files : TSCONFIG . include ,
5383 plugins : {
5484 "@next/next" : eslintPluginNext ,
5585 } ,
@@ -59,13 +89,13 @@ export default tseslint.config(
5989 } ,
6090 } ,
6191 {
62- files : [ ... GLOB_TS , ... GLOB_MDX ] ,
92+ files : GLOB_JS ,
6393 plugins : {
6494 "simple-import-sort" : eslintPluginSimpleImportSort ,
6595 } ,
6696 rules : {
67- "simple-import-sort/exports" : "warn" ,
6897 "simple-import-sort/imports" : "warn" ,
98+ "simple-import-sort/exports" : "warn" ,
6999 } ,
70100 } ,
71101 {
@@ -75,18 +105,12 @@ export default tseslint.config(
75105 } ,
76106 } ,
77107 {
78- files : [ ...GLOB_JS , ...GLOB_MDX ] ,
79- ...tseslint . configs . disableTypeChecked ,
80- } ,
81- {
82- files : GLOB_JS ,
108+ files : [ ...GLOB_JS , ...GLOB_CONFIG ] ,
83109 rules : {
110+ ...tseslint . configs . disableTypeChecked . rules ,
84111 "no-undef" : "off" ,
85- "@typescript-eslint/ no-require-imports " : "off" ,
112+ "no-console " : "off" ,
86113 } ,
87114 } ,
88115 gitignore ( ) ,
89- {
90- ignores : GLOB_CONFIG ,
91- } ,
92116) ;
0 commit comments