@@ -9,86 +9,96 @@ const compat = new FlatCompat({
99 baseDirectory : import . meta. dirname ,
1010} )
1111
12- const flatConfig = tsEslint . config (
13- eslint . configs . recommended ,
14- ...tsEslint . configs . strictTypeChecked ,
15- {
16- languageOptions : {
17- parserOptions : {
18- projectService : true , // alternative: `project: ['./tsconfig.json']` for older setups
19- } ,
20- } ,
21- } ,
12+ export const getConfiguration = ( {
13+ tsconfigRootDirectory,
14+ project,
15+ allowDefaultProject,
16+ } : {
17+ tsconfigRootDirectory : string
18+ project ?: string | boolean | string [ ] | null
19+ allowDefaultProject ?: string [ ]
20+ } ) => {
21+ const flatConfig = tsEslint . config (
22+ eslint . configs . recommended ,
23+ //...tsEslint.configs.strictTypeChecked,
2224
23- ...compat . extends ( "eslint-config-airbnb" ) ,
25+ ...compat . extends ( "eslint-config-airbnb" ) ,
2426
25- {
26- name : "@launchware/eslint-config-react/react" ,
27- files : [ "**/*.{js,jsx,ts,tsx}" ] ,
28- plugins : {
29- react : ( reactPlugin as any ) . default ?? reactPlugin ,
30- "jsx-a11y" : a11yPlugin ,
31- } ,
32- languageOptions : {
33- globals : globals . browser ,
34- parserOptions : {
35- ecmaFeatures : { jsx : true } ,
27+ {
28+ name : "@launchware/eslint-config-react/react" ,
29+ files : [ "src/**/*.ts" , "src/**/*.tsx" ] ,
30+ languageOptions : {
31+ globals : globals . browser ,
32+ parserOptions : {
33+ tsconfigRootDir : tsconfigRootDirectory ,
34+ project,
35+ ecmaFeatures : { jsx : true } ,
36+ projectService : {
37+ allowDefaultProject,
38+ } ,
39+ } ,
3640 } ,
37- } ,
38- rules : {
39- // General best practices
40- "no-shadow" : "off" ,
41- "no-use-before-define" : "off" ,
42- "no-underscore-dangle" : "off" ,
43- semi : "off" ,
41+ plugins : {
42+ react : ( reactPlugin as any ) . default ?? reactPlugin ,
43+ "jsx-a11y" : a11yPlugin ,
44+ } ,
45+ rules : {
46+ // General best practices
47+ "no-shadow" : "off" ,
48+ "no-use-before-define" : "off" ,
49+ "no-underscore-dangle" : "off" ,
50+ semi : "off" ,
4451
45- // TypeScript-specific
46- "@typescript-eslint/no-unused-vars" : [ "error" ] ,
52+ // TypeScript-specific
53+ // "@typescript-eslint/no-unused-vars": ["error"],
4754
48- // React-specific
49- "react/prop-types" : "off" ,
50- "react/react-in-jsx-scope" : "off" ,
51- "react/jsx-filename-extension" : [ "error" , { extensions : [ ".jsx" , ".tsx" ] } ] ,
52- "react/jsx-props-no-spreading" : "off" ,
55+ // React-specific
56+ "react/prop-types" : "off" ,
57+ "react/react-in-jsx-scope" : "off" ,
58+ "react/jsx-filename-extension" : [ "error" , { extensions : [ ".jsx" , ".tsx" ] } ] ,
59+ "react/jsx-props-no-spreading" : "off" ,
5360
54- // A11y
55- // (optional additions depending on your team’s commitment to accessibility)
61+ // A11y
62+ // (optional additions depending on your team’s commitment to accessibility)
5663
57- // Import rules
58- "import/extensions" : [ "off" ] ,
59- "import/order" : [
60- "error" ,
61- {
62- groups : [ "builtin" , "external" , "internal" , "parent" , "sibling" , "index" ] ,
63- pathGroups : [
64- {
65- pattern : "react" ,
66- group : "external" ,
67- position : "before" ,
64+ // Import rules
65+ "import/extensions" : [ "off" ] ,
66+ "import/order" : [
67+ "error" ,
68+ {
69+ groups : [ "builtin" , "external" , "internal" , "parent" , "sibling" , "index" ] ,
70+ pathGroups : [
71+ {
72+ pattern : "react" ,
73+ group : "external" ,
74+ position : "before" ,
75+ } ,
76+ ] ,
77+ pathGroupsExcludedImportTypes : [ "react" ] ,
78+ "newlines-between" : "always" ,
79+ alphabetize : {
80+ order : "asc" ,
81+ caseInsensitive : true ,
6882 } ,
69- ] ,
70- pathGroupsExcludedImportTypes : [ "react" ] ,
71- "newlines-between" : "always" ,
72- alphabetize : {
73- order : "asc" ,
74- caseInsensitive : true ,
7583 } ,
76- } ,
77- ] ,
78- "import/prefer-default-export" : "off" ,
79- "import/no-cycle" : "off" ,
80- "import/no-named-as-default" : "off" ,
81- "import/no-named-as-default-member" : "off" ,
84+ ] ,
85+ "import/prefer-default-export" : "off" ,
86+ "import/no-cycle" : "off" ,
87+ "import/no-named-as-default" : "off" ,
88+ "import/no-named-as-default-member" : "off" ,
89+ } ,
90+ }
91+ )
92+
93+ const config = {
94+ meta : {
95+ name : "@launchware/eslint-config-react" ,
96+ version : "0.2.0" ,
97+ } ,
98+ configs : {
99+ recommended : flatConfig ,
82100 } ,
83101 }
84- )
85102
86- export default {
87- meta : {
88- name : "@launchware/eslint-config-react" ,
89- version : "0.1.3" ,
90- } ,
91- configs : {
92- recommended : flatConfig ,
93- } ,
103+ return config
94104}
0 commit comments