Skip to content

Commit 1f825fa

Browse files
authored
feat: encapsulate ESLint configuration in a reusable factory function with an extraSourceFiles option. (baserow#4658)
1 parent 3da4797 commit 1f825fa

1 file changed

Lines changed: 77 additions & 70 deletions

File tree

eslint.config.mjs

Lines changed: 77 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,84 @@
11
// @ts-check
2-
import withNuxt from './web-frontend/.nuxt/eslint.config.mjs'
3-
import globals from './web-frontend/node_modules/globals/index.js'
4-
import vitest from './web-frontend/node_modules/eslint-plugin-vitest/dist/index.mjs'
5-
import eslintConfigPrettier from './web-frontend/node_modules/eslint-config-prettier/index.js'
2+
import withNuxt from "./web-frontend/.nuxt/eslint.config.mjs";
3+
import globals from "./web-frontend/node_modules/globals/index.js";
4+
import vitest from "./web-frontend/node_modules/eslint-plugin-vitest/dist/index.mjs";
5+
import eslintConfigPrettier from "./web-frontend/node_modules/eslint-config-prettier/index.js";
66

7-
export default withNuxt([
8-
{
9-
ignores: [
10-
'**/node_modules/**',
11-
'**/.nuxt/**',
12-
'**/coverage/**',
13-
'**/generated/**',
14-
'**/.nuxt-storybook/**',
15-
'**/dist/**',
16-
'**/.output/**',
17-
'**/.storybook/**',
18-
'**/vitest.setup.ts',
19-
],
20-
},
21-
eslintConfigPrettier, // deactivate eslint rules that conflict with prettier
22-
{
23-
files: [
24-
'web-frontend/**/*.{js,ts,mjs,mts,jsx,tsx,vue}',
25-
'premium/web-frontend/**/*.{js,ts,mjs,mts,jsx,tsx,vue}',
26-
'enterprise/web-frontend/**/*.{js,ts,mjs,mts,jsx,tsx,vue}',
27-
],
28-
languageOptions: {
29-
globals: {
30-
...globals.browser,
31-
...globals.node,
32-
},
33-
},
34-
rules: {
35-
'no-console': 0,
36-
'vue/no-mutating-props': 0,
37-
'import/order': 'off',
38-
'vue/html-self-closing': 'off',
39-
'vue/no-unused-components': 'warn',
40-
'vue/no-use-computed-property-like-method': 'off',
41-
'vue/multi-word-component-names': 'off',
42-
'vue/no-reserved-component-names': 'off',
43-
'import/no-named-as-default-member': 'off',
44-
'no-unused-vars': 'off',
45-
'@typescript-eslint/no-unused-vars': 'off',
46-
'@typescript-eslint/no-explicit-any': 'off',
47-
'@typescript-eslint/no-dynamic-delete': 'off',
48-
'no-empty': 'off',
7+
// Export factory function for reusability in plugins
8+
export const createBaserowConfig = ({ extraSourceFiles = [] } = {}) => {
9+
return withNuxt([
10+
{
11+
ignores: [
12+
"**/node_modules/**",
13+
"**/.nuxt/**",
14+
"**/coverage/**",
15+
"**/generated/**",
16+
"**/.nuxt-storybook/**",
17+
"**/dist/**",
18+
"**/.output/**",
19+
"**/.storybook/**",
20+
"**/vitest.setup.ts",
21+
],
4922
},
50-
},
51-
// Premium and Enterprise-specific overrides
52-
{
53-
files: [
54-
'premium/web-frontend/**/*.{js,ts,mjs,mts,jsx,tsx,vue}',
55-
'enterprise/web-frontend/**/*.{js,ts,mjs,mts,jsx,tsx,vue}',
56-
],
57-
rules: {
58-
'vue/order-in-components': 'off',
23+
eslintConfigPrettier, // deactivate eslint rules that conflict with prettier
24+
{
25+
files: [
26+
"web-frontend/**/*.{js,ts,mjs,mts,jsx,tsx,vue}",
27+
"premium/web-frontend/**/*.{js,ts,mjs,mts,jsx,tsx,vue}",
28+
"enterprise/web-frontend/**/*.{js,ts,mjs,mts,jsx,tsx,vue}",
29+
...extraSourceFiles,
30+
],
31+
languageOptions: {
32+
globals: {
33+
...globals.browser,
34+
...globals.node,
35+
},
36+
},
37+
rules: {
38+
"no-console": 0,
39+
"vue/no-mutating-props": 0,
40+
"import/order": "off",
41+
"vue/html-self-closing": "off",
42+
"vue/no-unused-components": "warn",
43+
"vue/no-use-computed-property-like-method": "off",
44+
"vue/multi-word-component-names": "off",
45+
"vue/no-reserved-component-names": "off",
46+
"import/no-named-as-default-member": "off",
47+
"no-unused-vars": "off",
48+
"@typescript-eslint/no-unused-vars": "off",
49+
"@typescript-eslint/no-explicit-any": "off",
50+
"@typescript-eslint/no-dynamic-delete": "off",
51+
"no-empty": "off",
52+
},
5953
},
60-
},
61-
// Test files configuration
62-
{
63-
files: [
64-
'**/*.{test,spec}.{js,ts,jsx,tsx}',
65-
'**/__tests__/**/*.{js,ts,jsx,tsx}',
66-
],
67-
plugins: { vitest },
68-
languageOptions: {
69-
globals: {
70-
...vitest.environments.env.globals,
54+
// Plugin specific overrides
55+
{
56+
files: [
57+
"premium/web-frontend/**/*.{js,ts,mjs,mts,jsx,tsx,vue}",
58+
"enterprise/web-frontend/**/*.{js,ts,mjs,mts,jsx,tsx,vue}",
59+
...extraSourceFiles, // Apply these rules to plugins too
60+
],
61+
rules: {
62+
"vue/order-in-components": "off",
7163
},
7264
},
73-
rules: {
74-
...vitest.configs.recommended.rules,
65+
// Test files configuration
66+
{
67+
files: [
68+
"**/*.{test,spec}.{js,ts,jsx,tsx}",
69+
"**/__tests__/**/*.{js,ts,jsx,tsx}",
70+
],
71+
plugins: { vitest },
72+
languageOptions: {
73+
globals: {
74+
...vitest.environments.env.globals,
75+
},
76+
},
77+
rules: {
78+
...vitest.configs.recommended.rules,
79+
},
7580
},
76-
},
77-
])
81+
]);
82+
};
83+
84+
export default createBaserowConfig();

0 commit comments

Comments
 (0)