1- const { defineConfig } = require ( 'eslint/config' ) ;
21const { includeIgnoreFile } = require ( '@eslint/compat' ) ;
3- const { rules : prettierConfigRules } = require ( 'eslint-config-prettier' ) ;
2+ const js = require ( '@eslint/js' ) ;
3+ const { defineConfig } = require ( 'eslint/config' ) ;
44const airbnb = require ( 'eslint-config-airbnb-extended' ) ;
5- const globals = require ( 'globals ' ) ;
5+ const eslintConfigPrettier = require ( 'eslint-config-prettier/flat ' ) ;
66const jest = require ( 'eslint-plugin-jest' ) ;
7- const js = require ( '@eslint/js' ) ;
87const jsxA11y = require ( 'eslint-plugin-jsx-a11y' ) ;
9- const path = require ( 'node:path' ) ;
108const playwright = require ( 'eslint-plugin-playwright' ) ;
11- const prettierPlugin = require ( 'eslint-plugin-prettier' ) ;
9+ const eslintPluginPrettier = require ( 'eslint-plugin-prettier/recommended ' ) ;
1210const reactCompiler = require ( 'eslint-plugin-react-compiler' ) ;
1311const unusedImports = require ( 'eslint-plugin-unused-imports' ) ;
12+ const globals = require ( 'globals' ) ;
13+ const path = require ( 'node:path' ) ;
14+
15+ const { isFormatSeparate } = require ( '../bin/commands/utils' ) ;
1416
1517const jsConfig = [
1618 {
@@ -30,34 +32,11 @@ const reactConfig = [
3032 ...airbnb . configs . react . recommended ,
3133] ;
3234
33- const typescriptConfig = [
34- // TypeScript ESLint Plugin
35- airbnb . plugins . typescriptEslint ,
36- // Airbnb Base TypeScript Config
37- ...airbnb . configs . base . typescript ,
38- // Airbnb React TypeScript Config
39- ...airbnb . configs . react . typescript ,
40- ] ;
41-
42- const prettierConfig = [
43- {
44- name : 'prettier/plugin/config' ,
45- plugins : {
46- prettier : prettierPlugin ,
47- } ,
48- } ,
49- {
50- name : 'prettier/config' ,
51- rules : {
52- ...prettierConfigRules ,
53- 'prettier/prettier' : 'error' ,
54- } ,
55- } ,
56- ] ;
35+ const typescriptConfig = [ airbnb . plugins . typescriptEslint , ...airbnb . configs . base . typescript , ...airbnb . configs . react . typescript ] ;
5736
5837const jestConfig = [
5938 {
60- files : [ '{src|tests}/**/*.{test|spec}.ts ' ] ,
39+ files : [ '{src|tests}/**/*.{test|spec}.{js,ts,jsx,tsx} ' ] ,
6140 plugins : { jest } ,
6241 languageOptions : {
6342 globals : jest . environments . globals . globals ,
@@ -68,27 +47,31 @@ const jestConfig = [
6847const playwrightConfig = [
6948 {
7049 ...playwright . configs [ 'flat/recommended' ] ,
71- files : [ 'playwright/**/*.{test|spec}.ts ' ] ,
50+ files : [ 'playwright/**/*.{test|spec}.{js,ts,jsx,tsx} ' ] ,
7251 } ,
7352] ;
7453
7554// Helper to disable jsx-a11y rules
76- const jsxA11yOffRules = Object . keys ( jsxA11y . rules ) . reduce ( ( acc , rule ) => {
77- acc [ `jsx-a11y/${ rule } ` ] = 'off' ;
78- return acc ;
79- } , { } ) ;
55+ const jsxA11yOffRules = Object . fromEntries ( Object . keys ( jsxA11y . rules ) . map ( ( rule ) => [ `jsx-a11y/${ rule } ` , 'off' ] ) ) ;
8056
81- module . exports = ( { tsconfigRootDir } ) =>
57+ module . exports = ( {
58+ tsconfigRootDir,
59+ includeJS,
60+ // For now, keep the prettier plugin enabled. Otherwise, we would have to add the prettier VSCode plugin and adapt workflows for everyone.
61+ // The visyn_scripts lint will automatically run prettier if this is enabled.
62+ includePrettierPlugin = ! isFormatSeparate ( ) ,
63+ } ) =>
8264 defineConfig (
8365 includeIgnoreFile ( path . resolve ( '.' , '.gitignore' ) ) ,
8466 ...jsConfig ,
8567 ...reactConfig ,
8668 ...typescriptConfig ,
87- ...prettierConfig ,
8869 ...jestConfig ,
8970 ...playwrightConfig ,
71+ // The prettier plugin contains both the config and the rule to run prettier as an eslint rule, whereas the config just disables conflicting rules (i.e. if you run prettier separately).
72+ ...( includePrettierPlugin ? [ eslintPluginPrettier ] : [ eslintConfigPrettier ] ) ,
9073 {
91- files : [ '**/*.{ts,tsx,cts,mts}' ] ,
74+ files : [ '**/*.{ts,tsx,cts,mts}' , ... ( includeJS ? [ '**/*.{js,jsx,cjs,mjs}' ] : [ ] ) ] ,
9275 plugins : {
9376 'unused-imports' : unusedImports ,
9477 } ,
@@ -105,14 +88,15 @@ module.exports = ({ tsconfigRootDir }) =>
10588 project : `./tsconfig.eslint.json` ,
10689 } ,
10790 globals : {
91+ ...globals . commonjs ,
92+ ...globals . jest ,
10893 ...globals . node ,
10994 ...globals . browser ,
11095 ...globals . es6 ,
11196 Atomics : 'readonly' ,
11297 SharedArrayBuffer : 'readonly' ,
11398 } ,
11499 } ,
115-
116100 rules : {
117101 ...jsxA11yOffRules ,
118102 'arrow-body-style' : 'off' ,
@@ -159,7 +143,7 @@ module.exports = ({ tsconfigRootDir }) =>
159143 } ,
160144 ] ,
161145 'prefer-arrow-callback' : 'warn' ,
162- '@typescript-eslint/no-require-imports' : 'warn ' ,
146+ '@typescript-eslint/no-require-imports' : 'off ' ,
163147 '@typescript-eslint/consistent-indexed-object-style' : 'off' ,
164148 '@typescript-eslint/consistent-type-definitions' : 'off' ,
165149 '@typescript-eslint/ban-ts-comment' : 'warn' ,
0 commit comments