@@ -14,11 +14,13 @@ const DEFAULT_ENCODING = {
1414const configTypes = {
1515 BABEL : 'babel' ,
1616 ESLINT : 'eslintConfig' ,
17+ SWC : 'swc' ,
1718} ;
1819
1920const configFiles = {
2021 BABEL : '.babelrc' ,
2122 ESLINT : '.eslintrc.json' ,
23+ SWC : '.swcrc' ,
2224} ;
2325
2426const JSX_MODULES = [ 'react' , 'preact' ] ;
@@ -35,18 +37,28 @@ const VAR_FILE_PATH = '$$filePath$$';
3537
3638const DEV = / \. d e v e l o p m e n t / ;
3739
38- const SUPPORTED_BABEL_FILES = [
39- / ^ b a b e l \. c o n f i g \. ( j | m j | c j | c t ) s $ / ,
40- / ^ b a b e l \. c o n f i g \. j s o n $ / ,
41- / ^ \. b a b e l r c \. ( j | m j | c j | c t ) s $ / ,
42- / ^ \. b a b e l r c \. j s o n $ / ,
43- / ^ \. b a b e l r c $ / ,
40+ const VALID_BABEL_FILES = [
41+ 'babel.config.js' ,
42+ 'babel.config.ts' ,
43+ 'babel.config.mjs' ,
44+ 'babel.config.cjs' ,
45+ 'babel.config.cts' ,
46+ 'babel.config.json' ,
47+ '.babelrc' ,
48+ '.babelrc.js' ,
49+ '.babelrc.ts' ,
50+ '.babelrc.mjs' ,
51+ '.babelrc.cjs' ,
52+ '.babelrc.cts' ,
53+ '.babelrc.json' ,
4454] ;
4555
46- const SUPPORTED_ESLINT_CONFIG_FILES = [
47- / ^ \. e s l i n t r c \. ( j | c j ) s $ / ,
48- / ^ \. e s l i n t r c \. ( y | y a ) m l $ / ,
49- / ^ \. e s l i n t r c \. j s o n $ / ,
56+ const VALID_ESLINTCONFIG_FILES = [
57+ '.eslintrc.js' ,
58+ '.eslintrc.cjs' ,
59+ '.eslintrc.yml' ,
60+ '.eslintrc.yaml' ,
61+ '.eslintrc.json' ,
5062] ;
5163
5264const MSG_INIT = 'Initializing...' ;
@@ -57,15 +69,18 @@ const MSG_LINTED = 'Completed in';
5769const MSG_LINTER = ( totalFiles , errorCount , warningCount ) =>
5870 `Checked ${ totalFiles } files! Found ${ errorCount } errors and ${ warningCount } warnings.` ;
5971const MSG_EMITTED = 'Emitted:' ;
60- const MSG_BABELRC = 'Using babel config from workspace' ;
72+ const MSG_BABELRC = 'Using babel from workspace' ;
6173const MSG_CONFIG = ( filename ) => `${ PREFIX } ${ filename } ` ;
6274const MSG_CONFIGBABEL = `${ PREFIX } .babelrc` ;
6375const MSG_CONFIGESLINT = `${ PREFIX } .eslintrc.json` ;
76+ const MSG_CONFIGSWC = `${ PREFIX } .swcrc` ;
6477const ERR_NOTFOUND = 'File not found!' ;
6578const ERR_ENTRYFILE =
6679 'Warning: Input file could not be resolved. Using "index.mjs" as default. Run the following command to configure "input" if you feel this is not right:' ;
6780const ERR_SILENT_VERBOSE =
6881 'Warning: "--verbose" is currently enabled. "--silent" will be ignored!' ;
82+ const ERR_SWC_ESLINT =
83+ 'Eslint currently does not support SWC. Switching to Babel instead.' ;
6984const CMD_INIT = `npx ${ SCRIPT_NAME } init` ;
7085const ERR_JSX_MODULE = ( modules ) =>
7186 `More than one JSX runtime detected ==> ${ modules . join ( ', ' ) } ` ;
@@ -87,8 +102,6 @@ const ESLINT_REACT_EXTENSIONS = [
87102 'plugin:react-hooks/recommended' ,
88103] ;
89104
90- const ESLINT_PREACT_EXTENSIONS = [ 'preact' ] ;
91-
92105module . exports = {
93106 DEV ,
94107 ROOT ,
@@ -102,15 +115,15 @@ module.exports = {
102115 ERR_NOTFOUND ,
103116 ERR_ENTRYFILE ,
104117 ERR_SILENT_VERBOSE ,
105- SUPPORTED_BABEL_FILES ,
106- SUPPORTED_ESLINT_CONFIG_FILES ,
118+ ERR_SWC_ESLINT ,
107119 MSG_EMITTED ,
108120 MSG_COMPILE ,
109121 MSG_COMPILED ,
110122 MSG_BABELRC ,
111123 MSG_CONFIG ,
112124 MSG_CONFIGBABEL ,
113125 MSG_CONFIGESLINT ,
126+ MSG_CONFIGSWC ,
114127 MSG_LINT ,
115128 MSG_LINTED ,
116129 MSG_LINTER ,
@@ -125,5 +138,6 @@ module.exports = {
125138 ESLINT_DEFAULT_EXTENSIONS ,
126139 ESLINT_TYPSCRIPT_EXTENSIONS ,
127140 ESLINT_REACT_EXTENSIONS ,
128- ESLINT_PREACT_EXTENSIONS ,
141+ VALID_BABEL_FILES ,
142+ VALID_ESLINTCONFIG_FILES ,
129143} ;
0 commit comments