@@ -19,13 +19,15 @@ import _ from 'lodash';
1919import tseslint from 'typescript-eslint' ;
2020
2121const DEFAULT_OPTS = {
22- typescript : false ,
22+ cypress : false ,
23+ cypressTestingLibrary : false ,
2324 react : false ,
25+ reactTestingLibrary : false ,
26+ rollup : false ,
2427 storybook : false ,
28+ typescript : false ,
29+ vite : false ,
2530 vitest : false ,
26- cypress : false ,
27- reactTestingLibrary : false ,
28- cypressTestingLibrary : false ,
2931} ;
3032
3133export function detectOpts ( projectDir ) {
@@ -39,28 +41,39 @@ export function detectOpts(projectDir) {
3941 ] ) ;
4042
4143 return {
42- typescript : deps . has ( 'typescript' ) && fs . existsSync ( tsconfigPath ) ,
44+ cypress : deps . has ( 'cypress' ) ,
45+ cypressTestingLibrary : deps . has ( '@testing-library/cypress' ) ,
4346 react : deps . has ( 'react' ) ,
47+ reactTestingLibrary : deps . has ( '@testing-library/react' ) ,
48+ rollup : deps . has ( 'rollup' ) ,
4449 storybook : deps . has ( 'storybook' ) ,
50+ typescript : deps . has ( 'typescript' ) && fs . existsSync ( tsconfigPath ) ,
51+ vite : deps . has ( 'vite' ) ,
4552 vitest : deps . has ( 'vitest' ) ,
46- cypress : deps . has ( 'cypress' ) ,
47- reactTestingLibrary : deps . has ( '@testing-library/react' ) ,
48- cypressTestingLibrary : deps . has ( '@testing-library/cypress' ) ,
4953 } ;
5054}
5155
5256// eslint-disable-next-line complexity
5357export function createConfig ( opts = { } ) {
5458 const {
55- typescript : withTypeScript ,
59+ cypress : withCypress ,
60+ cypressTestingLibrary : withCypressTestingLibrary ,
5661 react : withReact ,
62+ reactTestingLibrary : withReactTestingLibrary ,
63+ rollup : withRollup ,
5764 storybook : withStorybook ,
65+ typescript : withTypeScript ,
66+ vite : withVite ,
5867 vitest : withVitest ,
59- cypress : withCypress ,
60- reactTestingLibrary : withReactTestingLibrary ,
61- cypressTestingLibrary : withCypressTestingLibrary ,
6268 } = { ...DEFAULT_OPTS , ...opts } ;
6369
70+ const nodeFiles = [
71+ '**/eslint.*.{js,ts}' ,
72+ withCypress && '**/cypress.*.{js,ts}' ,
73+ withRollup && '**/rollup.*.{js,ts}' ,
74+ withVite && '**/vite.*.{js,ts}' ,
75+ ] ;
76+
6477 return tseslint . config (
6578 _ . compact ( [
6679 withTypeScript && {
@@ -93,8 +106,19 @@ export function createConfig(opts = {}) {
93106 } ,
94107 {
95108 /**
96- * Configure browser globals on files we're confident aren't meant to run
97- * in a non-browser environment.
109+ * Configure Node globals on files we're confident are meant to run
110+ * in a Node environment.
111+ */
112+ name : 'h5web/defaults/globals-node' ,
113+ files : nodeFiles . filter ( ( entry ) => ! ! entry ) ,
114+ languageOptions : {
115+ globals : { ...globals . node } ,
116+ } ,
117+ } ,
118+ {
119+ /**
120+ * Configure browser globals on files we're confident are meant to run
121+ * in a browser environment.
98122 */
99123 name : 'h5web/defaults/globals-browser' ,
100124 files : [ '**/*.{jsx,tsx}' ] ,
0 commit comments