diff options
| author | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2025-09-18 12:05:40 +0200 |
|---|---|---|
| committer | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2025-09-18 12:05:40 +0200 |
| commit | e60f343df5bf29744f6cdb1d0eda640e4a50f6b7 (patch) | |
| tree | c8a81ddbd2cf39d1bf55f9f07ee5a7f359817621 | |
| parent | 326b4763861663bda59de2d500761158f41be178 (diff) | |
| download | mullvadvpn-test-eslint-plugin-import.tar.xz mullvadvpn-test-eslint-plugin-import.zip | |
| -rw-r--r-- | desktop/packages/mullvad-vpn/eslint.config.mjs | 108 |
1 files changed, 83 insertions, 25 deletions
diff --git a/desktop/packages/mullvad-vpn/eslint.config.mjs b/desktop/packages/mullvad-vpn/eslint.config.mjs index 459f61a041..e53f3e7dd2 100644 --- a/desktop/packages/mullvad-vpn/eslint.config.mjs +++ b/desktop/packages/mullvad-vpn/eslint.config.mjs @@ -1,4 +1,5 @@ import eslintReact from '@eslint-react/eslint-plugin'; +import reactNamingConvention from 'eslint-plugin-react-naming-convention'; import importPlugin from 'eslint-plugin-import'; import perfectionist from 'eslint-plugin-perfectionist'; import react from 'eslint-plugin-react'; @@ -11,9 +12,9 @@ import workspaceConfig from '../../eslint.config.mjs'; export default [ ...workspaceConfig, react.configs.flat.recommended, - importPlugin.flatConfigs.typescript, + // importPlugin.flatConfigs.typescript, // perfectionist.configs['recommended-alphabetical'], - eslintReact.configs['recommended-typescript'], + // eslintReact.configs['off'], { ignores: ['build/', 'build-standalone/'] }, { files: ['**/*'], @@ -40,7 +41,6 @@ export default [ { files: ['**/*.{js,mjs,ts,tsx}'], plugins: { - perfectionist, 'react-hooks': reactHooks, 'react-compiler': reactcompiler, }, @@ -53,38 +53,96 @@ export default [ // }, // ], // 'import/no-cycle': 'error', - 'perfectionist/sort-exports': [ - 'error', - { - type: 'alphabetical', - order: 'asc', - }, - ], + // 'perfectionist/sort-exports': [ + // 'error', + // { + // type: 'alphabetical', + // order: 'asc', + // }, + // ], 'react-compiler/react-compiler': 'error', 'react-hooks/exhaustive-deps': 'error', 'react-hooks/rules-of-hooks': 'error', 'react/jsx-no-bind': 'error', - // 'react/jsx-sort-props': 'error', 'react/prop-types': 'off', 'react/react-in-jsx-scope': 'off', }, }, + // { + // files: ['src/renderer/**/*.{ts,tsx}'], + // rules: { + // // Allow function statement and allow use of arrow functions in the file but + // // only allow export of function statement + // 'func-style': [ + // 'error', + // 'declaration', + // { + // allowArrowFunctions: true, + // overrides: { + // namedExports: 'declaration', + // }, + // }, + // ], + // // Only allow named exports + // 'no-restricted-exports': [ + // 'error', + // { + // restrictDefaultExports: { + // direct: true, // Do not allow default exports + // named: true, // Do not allow exporting named as default + // defaultFrom: true, // Do not allow re-exporting default + // namedFrom: true, // Do not allow re-exporting named as default + // namespaceFrom: true, // Do not allow re-exporting * as default + // }, + // }, + // ], + // }, + // }, + // { + // files: ['src/renderer/**/*.tsx'], + // plugins: { + // '@eslint-react/naming-convention': reactNamingConvention, + // }, + // rules: { + // // Enforce naming standard of React Components + // '@eslint-react/naming-convention/filename': ['error', { rule: 'PascalCase' }], + // // Use .tsx or .ts extension as needed + // '@eslint-react/naming-convention/filename-extension': ['error', 'as-needed'], + // // Sort a React Component's props alphabetically + // 'react/jsx-sort-props': 'error', + // }, + // }, + // { + // files: ['src/renderer/**/hooks/use*.{ts}'], + // plugins: { + // '@eslint-react/naming-convention': reactNamingConvention, + // }, + // rules: { + // // Enforce naming standard of React hooks + // '@eslint-react/naming-convention/filename': ['error', { rule: 'kebab-case' }], + // }, + // }, { - files: ['src/**/*.{tsx}'], - rules: { - '@eslint-react/naming-convention/filename': ['warn', { rule: 'PascalCase' }], - }, - }, - { - files: ['src/**/hooks/use*.{ts}'], - rules: { - '@eslint-react/naming-convention/filename': ['warn', { rule: 'kebab-case' }], - }, - }, - { - files: ['**/*.tsx'], + files: ['src/renderer/**/*.{ts,tsx}'], rules: { - '@eslint-react/naming-convention/filename-extension': ['warn', 'as-needed'], + 'no-restricted-imports': [ + 'error', + { + // Allow imports only from index file of a barrel folder + patterns: [ + // Forbidden to import from barrel folder children directly + '**/components/*', + '**/hooks/*', + '**/utils/*', + // Allowed to import from barrel folder index + '!./components', + '!./hooks', + '!./utils', + // Design system component library + '!**/lib/components/*', + ], + }, + ], }, }, { |
