diff --git a/packages/manager/.changeset/pr-12100-tech-stories-1745464783439.md b/packages/manager/.changeset/pr-12100-tech-stories-1745464783439.md new file mode 100644 index 00000000000..2a980221c86 --- /dev/null +++ b/packages/manager/.changeset/pr-12100-tech-stories-1745464783439.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Tech Stories +--- + +Restrict Cypress imports to Cypress directory only ([#12100](https://github.com/linode/manager/pull/12100)) diff --git a/packages/manager/eslint.config.js b/packages/manager/eslint.config.js index 203bf75bece..3f45bc2da92 100644 --- a/packages/manager/eslint.config.js +++ b/packages/manager/eslint.config.js @@ -16,6 +16,26 @@ import { defineConfig } from 'eslint/config'; import globals from 'globals'; import tseslint from 'typescript-eslint'; +// Shared import restrictions between different rule contexts +const restrictedImportPaths = [ + 'rxjs', + '@mui/core', + '@mui/system', + '@mui/icons-material', + { + name: '@mui/material', + importNames: ['Typography'], + message: + 'Please use Typography component from @linode/ui instead of @mui/material', + }, + { + name: 'react-router-dom', + importNames: ['Link'], + message: + 'Please use the Link component from src/components/Link instead of react-router-dom', + }, +]; + export const baseConfig = [ // 1. Ignores { @@ -79,21 +99,15 @@ export const baseConfig = [ 'no-new-wrappers': 'error', 'no-restricted-imports': [ 'error', - 'rxjs', - '@mui/core', - '@mui/system', - '@mui/icons-material', { - importNames: ['Typography'], - message: - 'Please use Typography component from @linode/ui instead of @mui/material', - name: '@mui/material', - }, - { - importNames: ['Link'], - message: - 'Please use the Link component from src/components/Link instead of react-router-dom', - name: 'react-router-dom', + paths: restrictedImportPaths, + patterns: [ + { + group: ['**/cypress/**'], + message: + 'Cypress modules should only be imported in Cypress testing directories', + }, + ], }, ], 'no-restricted-syntax': [ @@ -115,6 +129,12 @@ export const baseConfig = [ 'spaced-comment': 'warn', }, }, + { + files: ['**/cypress.config.ts'], + rules: { + 'no-restricted-imports': 'off', + }, + }, // 5. React and React Hooks { @@ -366,6 +386,14 @@ export const baseConfig = [ 'sonarjs/no-hardcoded-ip': 'off', '@linode/cloud-manager/no-createLinode': 'error', '@typescript-eslint/no-unused-expressions': 'off', + // Maintain standard import restrictions but allow Cypress imports + 'no-restricted-imports': [ + 'error', + { + paths: restrictedImportPaths, + // Intentionally omit patterns to allow Cypress imports here + }, + ], }, },