From 211fe72be6d9a3c46cff078a7db8f9b789f771bf Mon Sep 17 00:00:00 2001 From: Alex Sanders Date: Wed, 22 May 2024 16:37:14 +0100 Subject: [PATCH 1/2] remove source eslint plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit they've not been updated since v3 → v4 and don't check anything. they also dont' apply the new single source package --- Makefile | 48 --- README.md | 20 - .../.eslintrc.cjs | 39 -- .../CHANGELOG.md | 206 ----------- .../README.md | 48 --- .../jest.config.js | 12 - .../jest.dist.setup.js | 8 - .../package.json | 113 ------ .../rollup.config.js | 1 - .../src/index.test.ts | 5 - .../src/index.ts | 19 - .../rules/no-star-imports-or-exports.test.ts | 145 -------- .../src/rules/no-star-imports-or-exports.ts | 63 ---- .../src/rules/valid-import-path.test.ts | 289 --------------- .../src/rules/valid-import-path.ts | 344 ------------------ .../tsconfig.json | 11 - .../tsconfig.spec.json | 21 -- .../.eslintrc.cjs | 39 -- .../CHANGELOG.md | 268 -------------- .../README.md | 49 --- .../jest.config.js | 12 - .../jest.dist.setup.js | 8 - .../package.json | 116 ------ .../rollup.config.js | 1 - .../src/index.test.ts | 5 - .../src/index.ts | 21 -- .../src/rules/valid-import-path.test.ts | 128 ------- .../src/rules/valid-import-path.ts | 344 ------------------ .../tsconfig.json | 11 - .../tsconfig.spec.json | 21 -- pnpm-lock.yaml | 254 +++---------- 31 files changed, 45 insertions(+), 2624 deletions(-) delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/.eslintrc.cjs delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/CHANGELOG.md delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/README.md delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/jest.config.js delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/jest.dist.setup.js delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/package.json delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/rollup.config.js delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/src/index.test.ts delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/src/index.ts delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/src/rules/no-star-imports-or-exports.test.ts delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/src/rules/no-star-imports-or-exports.ts delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/src/rules/valid-import-path.test.ts delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/src/rules/valid-import-path.ts delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/tsconfig.json delete mode 100644 libs/@guardian/eslint-plugin-source-foundations/tsconfig.spec.json delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/.eslintrc.cjs delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/CHANGELOG.md delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/README.md delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/jest.config.js delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/jest.dist.setup.js delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/package.json delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/rollup.config.js delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/src/index.test.ts delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/src/index.ts delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/src/rules/valid-import-path.test.ts delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/src/rules/valid-import-path.ts delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/tsconfig.json delete mode 100644 libs/@guardian/eslint-plugin-source-react-components/tsconfig.spec.json diff --git a/Makefile b/Makefile index 994763b15..2ed1531e0 100644 --- a/Makefile +++ b/Makefile @@ -257,54 +257,6 @@ install: check-node-version @guardian/eslint-config-typescript\:lint: env @corepack pnpm --filter @guardian/eslint-config-typescript lint -.PHONY: @guardian/eslint-plugin-source-foundations\:build -@guardian/eslint-plugin-source-foundations\:build: env - @corepack pnpm --filter @guardian/eslint-plugin-source-foundations build - -.PHONY: @guardian/eslint-plugin-source-foundations\:dev -@guardian/eslint-plugin-source-foundations\:dev: env - @corepack pnpm --filter @guardian/eslint-plugin-source-foundations dev - -.PHONY: @guardian/eslint-plugin-source-foundations\:fix -@guardian/eslint-plugin-source-foundations\:fix: env - @corepack pnpm --filter @guardian/eslint-plugin-source-foundations fix - -.PHONY: @guardian/eslint-plugin-source-foundations\:lint -@guardian/eslint-plugin-source-foundations\:lint: env - @corepack pnpm --filter @guardian/eslint-plugin-source-foundations lint - -.PHONY: @guardian/eslint-plugin-source-foundations\:test -@guardian/eslint-plugin-source-foundations\:test: env - @corepack pnpm --filter @guardian/eslint-plugin-source-foundations test - -.PHONY: @guardian/eslint-plugin-source-foundations\:verify-dist -@guardian/eslint-plugin-source-foundations\:verify-dist: env - @corepack pnpm --filter @guardian/eslint-plugin-source-foundations verify-dist - -.PHONY: @guardian/eslint-plugin-source-react-components\:build -@guardian/eslint-plugin-source-react-components\:build: env - @corepack pnpm --filter @guardian/eslint-plugin-source-react-components build - -.PHONY: @guardian/eslint-plugin-source-react-components\:dev -@guardian/eslint-plugin-source-react-components\:dev: env - @corepack pnpm --filter @guardian/eslint-plugin-source-react-components dev - -.PHONY: @guardian/eslint-plugin-source-react-components\:fix -@guardian/eslint-plugin-source-react-components\:fix: env - @corepack pnpm --filter @guardian/eslint-plugin-source-react-components fix - -.PHONY: @guardian/eslint-plugin-source-react-components\:lint -@guardian/eslint-plugin-source-react-components\:lint: env - @corepack pnpm --filter @guardian/eslint-plugin-source-react-components lint - -.PHONY: @guardian/eslint-plugin-source-react-components\:test -@guardian/eslint-plugin-source-react-components\:test: env - @corepack pnpm --filter @guardian/eslint-plugin-source-react-components test - -.PHONY: @guardian/eslint-plugin-source-react-components\:verify-dist -@guardian/eslint-plugin-source-react-components\:verify-dist: env - @corepack pnpm --filter @guardian/eslint-plugin-source-react-components verify-dist - .PHONY: @guardian/identity-auth\:build @guardian/identity-auth\:build: env @corepack pnpm --filter @guardian/identity-auth build diff --git a/README.md b/README.md index 5485a196f..a8a4044b2 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,6 @@ The following packages live in `libs/@guardian/*` and are published to NPM: - [@guardian/core-web-vitals](libs/@guardian/core-web-vitals) - [@guardian/eslint-config](libs/@guardian/eslint-config) - [@guardian/eslint-config-typescript](libs/@guardian/eslint-config-typescript) -- [@guardian/eslint-plugin-source-foundations](libs/@guardian/eslint-plugin-source-foundations) -- [@guardian/eslint-plugin-source-react-components](libs/@guardian/eslint-plugin-source-react-components) - [@guardian/identity-auth](libs/@guardian/identity-auth) - [@guardian/identity-auth-frontend](libs/@guardian/identity-auth-frontend) - [@guardian/libs](libs/@guardian/libs) @@ -129,24 +127,6 @@ Project-specific tasks are defined as `scripts` in a `package.json` or `targets` - `make @guardian/eslint-config-typescript:fix` - `make @guardian/eslint-config-typescript:lint` -#### @guardian/eslint-plugin-source-foundations - -- `make @guardian/eslint-plugin-source-foundations:build` -- `make @guardian/eslint-plugin-source-foundations:dev` -- `make @guardian/eslint-plugin-source-foundations:fix` -- `make @guardian/eslint-plugin-source-foundations:lint` -- `make @guardian/eslint-plugin-source-foundations:test` -- `make @guardian/eslint-plugin-source-foundations:verify-dist` - -#### @guardian/eslint-plugin-source-react-components - -- `make @guardian/eslint-plugin-source-react-components:build` -- `make @guardian/eslint-plugin-source-react-components:dev` -- `make @guardian/eslint-plugin-source-react-components:fix` -- `make @guardian/eslint-plugin-source-react-components:lint` -- `make @guardian/eslint-plugin-source-react-components:test` -- `make @guardian/eslint-plugin-source-react-components:verify-dist` - #### @guardian/identity-auth - `make @guardian/identity-auth:build` diff --git a/libs/@guardian/eslint-plugin-source-foundations/.eslintrc.cjs b/libs/@guardian/eslint-plugin-source-foundations/.eslintrc.cjs deleted file mode 100644 index 846cd70f7..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/.eslintrc.cjs +++ /dev/null @@ -1,39 +0,0 @@ -module.exports = { - extends: ['../../../.eslintrc.cjs'], - ignorePatterns: [ - '!**/*', - 'node_modules', - 'jest.dist.*', // depends on build output, so don't lint it - 'dist', - '.wireit', - ], - overrides: [ - { - files: ['*.ts', '*.tsx'], - parserOptions: { - tsconfigRootDir: __dirname, - }, - rules: {}, - }, - { - files: ['*.ts', '*.tsx'], - rules: {}, - }, - { - files: ['*.js', '*.jsx'], - rules: {}, - }, - { - files: ['*.test.*', 'jest.*'], - env: { - jest: true, - }, - rules: { - '@typescript-eslint/no-unsafe-call': 'off', - '@typescript-eslint/no-unsafe-assignment': 'off', - '@typescript-eslint/restrict-template-expressions': 'off', - '@typescript-eslint/no-unsafe-member-access': 'off', - }, - }, - ], -}; diff --git a/libs/@guardian/eslint-plugin-source-foundations/CHANGELOG.md b/libs/@guardian/eslint-plugin-source-foundations/CHANGELOG.md deleted file mode 100644 index 27f431e51..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/CHANGELOG.md +++ /dev/null @@ -1,206 +0,0 @@ -# @guardian/eslint-plugin-source-foundations - -## 18.0.1 - -### Patch Changes - -- 0382052: 1. All packages are now ES modules, although they should be compatible with CommonJS environments. 2. Adds entry points for projects that can consume [`package.json#exports`](https://nodejs.org/api/packages.html#exports), alongside `main`. - -## 18.0.0 - -### Major Changes - -- 145ba2a: Updated dependencies - - @guardian/source-foundations@14.1.4 - -## 17.0.2 - -### Patch Changes - -- a6eb679: Update @typescript-eslint/eslint-plugin and @typescript-eslint/parser - -## 17.0.1 - -### Patch Changes - -- 225e542: Dependencies updates: - - - `@typescript-eslint/eslint-plugin` from 6.14.0 to 6.18.0 - - `@typescript-eslint/parser` from 6.14.0 to 6.18.0 - -## 17.0.0 - -### Major Changes - -- Update TS to version 5.3.3 and tslib to 2.6.2 - -- Updated dependencies - - @guardian/source-foundations@14.0.0 - - @guardian/libs@16.0.0 - -## 16.0.1 - -### Patch Changes - -- a116dfe: Update @typescript-eslint/parser and @typescript-eslint/eslint-plugin - -## 16.0.0 - -### Major Changes - -- 9e0cb43: `@typescript-eslint/eslint-plugin` and `@typescript-eslint/parser` dependencies upgraded to next major version (6). - -## 15.0.0 - -### Major Changes - -- 6bb3297: Updates ESLint to latest version to fix security vulnerability in `word-wrap` dependency - -## 14.0.0 - -### Major Changes - -- Use latest Guardian packages - -## 13.0.0 - -### Major Changes - -- Update Typescript to v5.1.3 and tslib to v2.5.3 - -### Patch Changes - -- Updated dependencies - - @guardian/libs@15.0.0 - -## 12.0.0 - -### Major Changes - -- Update Source package versions - -## 11.0.0 - -### Major Changes - -- Now requires TypeScript ~4.9.5 (if you use it with TypeScript). - -### Patch Changes - -- Updated dependencies - - @guardian/libs@14.0.0 - - @guardian/source-foundations@10.0.0 - -## 10.0.0 - -### Major Changes - -- c6366dd: Add `tslib@^2.4.1` to peerDependencies - -### Patch Changes - -- Updated dependencies [c6366dd] -- Updated dependencies [b4104c1] -- Updated dependencies [05a5836] - - @guardian/source-foundations@9.0.0 - - @guardian/libs@13.0.0 - -## 9.0.3 - -### Patch Changes - -- 7cd6f21: Bump tslib to v2.4.1 - -## 9.0.2 - -### Patch Changes - -- cf437f9: Bump @guardian/source-foundations to v8 - -## 9.0.1 - -### Patch Changes - -- d742b50: Bump @guardian/libs to 12.0.0 - -## 9.0.0 - -### Major Changes - -- eb65fde: Add `typescript@^4.3.2` to `peerDependecies` (`optional`). - - This should mean you get a warning if you're using an incompatible version of typescript, but not if you aren't using it at all. - -### Patch Changes - -- Updated dependencies [eb65fde] - - @guardian/libs@11.0.0 - - @guardian/source-foundations@8.0.0 - -## 8.0.4 - -### Patch Changes - -- 0e11603: Links in `eslint-plugin-source-foundations` and `eslint-plugin-source-react-components` eslint documentation updated to point at the relevant readme instead of the archived Source repo. - -## 8.0.3 - -### Patch Changes - -- a442275: Declare compatability with `@guardian/libs@^10.0.0` - -## 8.0.2 - -### Patch Changes - -- 24ad7d0: Update dependencies - -## 8.0.1 - -### Patch Changes - -- 2033774: No op to test release process - -## 8.0.0 - -### Major Changes - -- aa4c2caa: Bump @guardian/libs to `^9.0.0` - -## 7.0.0 - -### Major Changes - -- Updated `peerDependencies` [905c5148] - - @guardian/source-foundations@7.0.0 - -## 6.0.1 - -### Patch Changes - -- 40e41a43: **No changes**: Patch bump to fix deploy to npm due to the major version already having been published and deleted - -## 6.0.0 - -### Patch Changes - -- Updated dependencies [3823490a] - - @guardian/source-foundations@6.0.0 - -## 5.0.1 - -### Patch Changes - -- 5c23c1d1: Remove `console.log` from `valid-foundations-import-path` rule - -## 5.0.0 - -### Patch Changes - -- Updated dependencies [b87baf5c] -- Updated dependencies [1e129d0b] -- Updated dependencies [8bd1adce] -- Updated dependencies [51f8737e] -- Updated dependencies [f6865ac5] -- Updated dependencies [34ec716d] - - @guardian/source-foundations@5.0.0 diff --git a/libs/@guardian/eslint-plugin-source-foundations/README.md b/libs/@guardian/eslint-plugin-source-foundations/README.md deleted file mode 100644 index 16de065e1..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# `@guardian/eslint-plugin-source-foundations` - -> ESLint plugin for Guardian projects using the `@guardian/source-foundations` package. - -This package is part of the [Source design system](/docs/source/README.md). - -## Installation - -```bash -yarn add -D @guardian/eslint-plugin-source-foundations -``` - -or - -```bash -npm install --save-dev @guardian/eslint-plugin-source-foundations -``` - -## Usage - -```js -// ESLint configuration file -{ - "extends": "plugin:@guardian/source-foundations/recommended" -} -``` - -## Rules - -### Valid import path - -This rules errors for imports from `@guardian/src-foundations` or any sub module. If possible, it will autofix the import to the new location. - -Some breaking changes can not be autofixed, for example, in cases where the export has been removed from Source. Developers must manually provide an alternative. - -### No \* imports or exports - -This rule errors for import or export `*` statements from any `src-*` or `source-*` package as this pattern is not recommended. - -### No duplicate imports - -This rule, from [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import), errors when multiple import statements import from the same pacakge. These issues can be autofixed. This rule is included as, due to the remove of sub modules and the consolidation of component packages, many import statements are fixed by the `valid-import-path` rule to import from the same location in v4. - -## Known Issues - -- New theme names not always updated automatically - - The theme variables have changed both name and location in the v4. The plugin should automatically update both but sometimes this does not work. diff --git a/libs/@guardian/eslint-plugin-source-foundations/jest.config.js b/libs/@guardian/eslint-plugin-source-foundations/jest.config.js deleted file mode 100644 index cb1055048..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/jest.config.js +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-disable import/no-default-export -- that's what jest likes */ - -import { config as baseConfig } from '../../../configs/jest.config.js'; - -/** @typedef {import("jest").Config} Config */ -const config = { - ...baseConfig, - displayName: '@guardian/eslint-plugin-source-foundations', - testEnvironment: 'node', -}; - -export default config; diff --git a/libs/@guardian/eslint-plugin-source-foundations/jest.dist.setup.js b/libs/@guardian/eslint-plugin-source-foundations/jest.dist.setup.js deleted file mode 100644 index f17485880..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/jest.dist.setup.js +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable -- this file will break unless the project is built, so let's not worry about it */ - -// Mock `src/index` with whatever the dist `package.json` points at. -// This means we can run `src/index.test.ts` against `dist` instead. - -import * as dist from '.'; - -jest.mock('./src/index', () => dist); diff --git a/libs/@guardian/eslint-plugin-source-foundations/package.json b/libs/@guardian/eslint-plugin-source-foundations/package.json deleted file mode 100644 index 96c22d571..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/package.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "name": "@guardian/eslint-plugin-source-foundations", - "version": "18.0.1", - "description": "ESLint plugin for Guardian projects using the `@guardian/source-foundations` package.", - "type": "module", - "exports": { - "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" - }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "files": [ - "dist" - ], - "scripts": { - "build": "wireit", - "dev": "jest --watch", - "fix": "wireit", - "lint": "wireit", - "test": "wireit", - "verify-dist": "wireit" - }, - "dependencies": { - "@typescript-eslint/eslint-plugin": "6.21.0", - "@typescript-eslint/parser": "6.21.0", - "eslint-plugin-import": "2.29.1" - }, - "devDependencies": { - "@guardian/libs": "16.0.0", - "@guardian/source-foundations": "14.1.4", - "@types/eslint": "8.56.1", - "@types/estree": "1.0.5", - "eslint": "8.56.0", - "rollup": "4.17.2", - "tslib": "2.6.2", - "typescript": "5.3.3", - "wireit": "0.14.4" - }, - "peerDependencies": { - "@guardian/libs": "^16.0.0", - "@guardian/source-foundations": "^14.1.4", - "@types/eslint": "^8.56.1", - "eslint": "^8.56.0", - "tslib": "^2.6.2", - "typescript": "~5.3.3" - }, - "peerDependenciesMeta": { - "@types/eslint": { - "optional": true - }, - "typescript": { - "optional": true - } - }, - "wireit": { - "build": { - "command": "rollup -c", - "files": [ - "../../../configs/rollup/rollup.config.js", - "./rollup.config.js", - "src/**", - "package.json", - "tsconfig.json" - ], - "output": [ - "dist" - ] - }, - "fix": { - "command": "eslint --cache --color . --fix", - "clean": false, - "files": [ - "!(dist)/**", - "!(.eslintcache)", - "../../../.eslint*" - ], - "output": [ - "." - ] - }, - "lint": { - "command": "eslint --cache --color .", - "files": [ - "!(dist)/**", - "!(.eslintcache)", - "../../../.eslint*" - ], - "output": [] - }, - "test": { - "command": "jest", - "files": [ - "!(dist)/**", - "!(.eslintcache)", - "../../../jest.*" - ], - "output": [] - }, - "verify-dist": { - "command": "jest --setupFilesAfterEnv ./jest.dist.setup.js", - "dependencies": [ - "build" - ], - "files": [ - "!(dist)/**", - "!(.eslintcache)", - "../../../jest.*" - ], - "output": [] - } - } -} diff --git a/libs/@guardian/eslint-plugin-source-foundations/rollup.config.js b/libs/@guardian/eslint-plugin-source-foundations/rollup.config.js deleted file mode 100644 index 93b094d39..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/rollup.config.js +++ /dev/null @@ -1 +0,0 @@ -export * as default from '../../../configs/rollup/rollup.config.js'; diff --git a/libs/@guardian/eslint-plugin-source-foundations/src/index.test.ts b/libs/@guardian/eslint-plugin-source-foundations/src/index.test.ts deleted file mode 100644 index 150fe654e..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/src/index.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as pkgExports from './index'; - -it('Should have exactly these exports', () => { - expect(Object.keys(pkgExports).sort()).toEqual(['configs', 'rules']); -}); diff --git a/libs/@guardian/eslint-plugin-source-foundations/src/index.ts b/libs/@guardian/eslint-plugin-source-foundations/src/index.ts deleted file mode 100644 index 6b7dd0dd4..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/src/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { noStarImportsOrExports } from './rules/no-star-imports-or-exports'; -import { validFoundationsImportPath } from './rules/valid-import-path'; - -export const rules = { - 'valid-foundations-import-path': validFoundationsImportPath, - 'no-star-imports-or-exports': noStarImportsOrExports, -}; - -export const configs = { - recommended: { - plugins: ['@guardian/source-foundations', 'import'], - - rules: { - '@guardian/source-foundations/valid-foundations-import-path': 'error', - '@guardian/source-foundations/no-star-imports-or-exports': 'error', - 'import/no-duplicates': 'error', - }, - }, -}; diff --git a/libs/@guardian/eslint-plugin-source-foundations/src/rules/no-star-imports-or-exports.test.ts b/libs/@guardian/eslint-plugin-source-foundations/src/rules/no-star-imports-or-exports.test.ts deleted file mode 100644 index a7516c416..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/src/rules/no-star-imports-or-exports.test.ts +++ /dev/null @@ -1,145 +0,0 @@ -import { RuleTester } from 'eslint'; -import { noStarImportsOrExports } from './no-star-imports-or-exports'; - -const ruleTester = new RuleTester({ - parser: require.resolve('@typescript-eslint/parser'), - parserOptions: { - ecmaVersion: 2020, - sourceType: 'module', - }, -}); - -ruleTester.run('no-star-imports-or-exports', noStarImportsOrExports, { - valid: [ - `import { Label } from '@guardian/source-react-components'`, - `import type { LabelProps } from '@guardian/source-react-components'`, - `import { breakpoints } from '@guardian/source-foundations'`, - `import type { Breakpoint } from '@guardian/source-foundations'`, - `import { Label } from '@guardian/src-label'`, - `import type { LabelProps } from '@guardian/src-label'`, - `import { breakpoints } from '@guardian/src-foundations'`, - `import type { Breakpoint } from '@guardian/src-foundations'`, - ], - invalid: [ - { - // Import everything - code: `import * as themes from '@guardian/src-foundations/themes';`, - errors: [ - { - message: - 'Importing * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named imports instead.', - }, - ], - }, - { - // Export everything from a component - code: `export * from '@guardian/src-button';`, - errors: [ - { - message: - 'Exporting * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named exports instead.', - }, - ], - }, - { - // Export everything from the root of foundations - code: `export * from '@guardian/src-foundations';`, - errors: [ - { - message: - 'Exporting * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named exports instead.', - }, - ], - }, - { - // Export everything with an alias from the root of foundations - code: `export * as foundations from '@guardian/src-foundations';`, - errors: [ - { - message: - 'Exporting * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named exports instead.', - }, - ], - }, - { - // Export everything from a submodule of foundations - code: `export * from '@guardian/src-foundations/size';`, - errors: [ - { - message: - 'Exporting * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named exports instead.', - }, - ], - }, - { - // Export everything from helpers - code: `export * from '@guardian/src-helpers';`, - errors: [ - { - message: - 'Exporting * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named exports instead.', - }, - ], - }, - { - // Import everything from source-foundations - code: `import * as foundations from '@guardian/source-foundations';`, - errors: [ - { - message: - 'Importing * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named imports instead.', - }, - ], - }, - { - // Import everything from source-react-components - code: `import * as components from '@guardian/source-react-components';`, - errors: [ - { - message: - 'Importing * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named imports instead.', - }, - ], - }, - { - // Import everything from source-react-components-development-kitchen - code: `import * as kitchen from '@guardian/source-react-components-development-kitchen';`, - errors: [ - { - message: - 'Importing * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named imports instead.', - }, - ], - }, - { - // Export everything from source-foundations - code: `export * from '@guardian/source-foundations';`, - errors: [ - { - message: - 'Exporting * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named exports instead.', - }, - ], - }, - { - // Export everything from source-react-components - code: `export * from '@guardian/source-react-components';`, - errors: [ - { - message: - 'Exporting * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named exports instead.', - }, - ], - }, - { - // Export everything from source-react-components-development-kitchen - code: `export * from '@guardian/source-react-components-development-kitchen';`, - errors: [ - { - message: - 'Exporting * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named exports instead.', - }, - ], - }, - ], -}); diff --git a/libs/@guardian/eslint-plugin-source-foundations/src/rules/no-star-imports-or-exports.ts b/libs/@guardian/eslint-plugin-source-foundations/src/rules/no-star-imports-or-exports.ts deleted file mode 100644 index cafb46bec..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/src/rules/no-star-imports-or-exports.ts +++ /dev/null @@ -1,63 +0,0 @@ -import type { Rule } from 'eslint'; -import type { ExportAllDeclaration, ImportDeclaration } from 'estree'; - -type Node = (ImportDeclaration | ExportAllDeclaration) & - Rule.NodeParentExtension; - -const isSourcePackage = (node: Node): boolean => { - const source = node.source.raw; - if (!source) { - return false; - } - - return ( - source.startsWith("'@guardian/src-") || - source.startsWith("'@guardian/source-") - ); -}; - -export const noStarImportsOrExports: Rule.RuleModule = { - meta: { - type: 'problem', - docs: { - description: 'Disallow * imports and exports', - category: 'Possible Problems', - url: 'https://github.com/guardian/csnx/tree/main/libs/@guardian/eslint-plugin-source-foundations/README.md', - }, - }, - - create(context: Rule.RuleContext): Rule.RuleListener { - return { - ImportDeclaration(node) { - if (!isSourcePackage(node)) { - return; - } - - const anyNamespaceSpecifiers = !node.specifiers.every( - (s) => s.type !== 'ImportNamespaceSpecifier', - ); - - if (!anyNamespaceSpecifiers) { - return; - } - - return context.report({ - node, - message: - 'Importing * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named imports instead.', - }); - }, - ExportAllDeclaration(node) { - // e.g. export * from '@guardian/src-foundations'` - if (!isSourcePackage(node)) { - return; - } - return context.report({ - node, - message: - 'Exporting * from @guardian/src-* and @guardian/source-* packages is not recommended. Use named exports instead.', - }); - }, - }; - }, -}; diff --git a/libs/@guardian/eslint-plugin-source-foundations/src/rules/valid-import-path.test.ts b/libs/@guardian/eslint-plugin-source-foundations/src/rules/valid-import-path.test.ts deleted file mode 100644 index 2688c7b30..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/src/rules/valid-import-path.test.ts +++ /dev/null @@ -1,289 +0,0 @@ -import { RuleTester } from 'eslint'; -import { validFoundationsImportPath } from './valid-import-path'; - -const ruleTester = new RuleTester({ - parser: require.resolve('@typescript-eslint/parser'), - parserOptions: { - ecmaVersion: 2020, - sourceType: 'module', - }, -}); - -const invalidFoundationsCases = [ - { - // A single import from the root of foundations - code: "import { transitions } from '@guardian/src-foundations';", - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-foundations' instead.", - }, - ], - output: "import { transitions } from '@guardian/source-foundations';", - }, - { - // A single import from a sub-module of foundations - code: "import { height } from '@guardian/src-foundations/size';", - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-foundations' instead.", - }, - ], - output: "import { height } from '@guardian/source-foundations';", - }, - { - // A single type import from the root of foundations - code: "import type { Breakpoint } from '@guardian/src-foundations';", - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-foundations' instead.", - }, - ], - output: "import type { Breakpoint } from '@guardian/source-foundations';", - }, - { - // A single type import from a sub-module of foundations - code: "import type { Breakpoint } from '@guardian/src-foundations/mq';", - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-foundations' instead.", - }, - ], - output: "import type { Breakpoint } from '@guardian/source-foundations';", - }, - { - // Exports that aren't available from foundations any more - code: `import { remSize } from '@guardian/src-foundations/size/global';`, - errors: [ - { - message: 'The following export(s) have been removed: remSize.', - }, - ], - output: `import { remSize } from '@guardian/src-foundations/size/global';`, - }, - { - // Exports that aren't available from foundations any more, plus one that is - code: `import { remSize, size } from '@guardian/src-foundations/size/global';`, - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-foundations' instead.\nThe following export(s) have been removed: remSize.", - }, - ], - output: `import { remSize } from '@guardian/src-foundations/size/global'; -import { size } from '@guardian/source-foundations';`, - }, - { - // Exports that aren't available from foundations any more using an alias - code: `import { remSize as rs } from '@guardian/src-foundations/size/global';`, - errors: [ - { - message: 'The following export(s) have been removed: remSize.', - }, - ], - output: `import { remSize as rs } from '@guardian/src-foundations/size/global';`, - }, - { - // Exports that aren't available from foundations any more using an alias, plus one that is - code: `import { remSize as rs, size as s } from '@guardian/src-foundations/size/global';`, - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-foundations' instead.\nThe following export(s) have been removed: remSize.", - }, - ], - output: `import { remSize as rs } from '@guardian/src-foundations/size/global'; -import { size as s } from '@guardian/source-foundations';`, - }, - { - // Exports that have changed names (foundations typography) - code: `import { headline } from '@guardian/src-foundations/typography/obj';`, - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-foundations' instead.\nThe following export(s) have been renamed [from -> to]: headline -> headlineObjectStyles", - }, - ], - output: `import { headline } from '@guardian/source-foundations';`, - }, - { - // Exports that have changed names, alongside some that haven't - code: `import { headline, bodySizes } from '@guardian/src-foundations/typography/obj';`, - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-foundations' instead.\nThe following export(s) have been renamed [from -> to]: headline -> headlineObjectStyles", - }, - ], - output: `import { headline, bodySizes } from '@guardian/source-foundations';`, - }, - { - // Exports that have changed names using an alias (foundations typography) - code: `import { headline as hl } from '@guardian/src-foundations/typography/obj';`, - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-foundations' instead.\nThe following export(s) have been renamed [from -> to]: headline -> headlineObjectStyles", - }, - ], - output: `import { headline as hl } from '@guardian/source-foundations';`, - }, - { - // Exports that have changed names, alongside some that haven't, using an alias - code: `import { headline as hl, bodySizes as bs } from '@guardian/src-foundations/typography/obj';`, - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-foundations' instead.\nThe following export(s) have been renamed [from -> to]: headline -> headlineObjectStyles", - }, - ], - output: `import { headline as hl, bodySizes as bs } from '@guardian/source-foundations';`, - }, - { - // Themes that now come from react-components and have changed names (from foundations) - code: `import { labelDefault } from '@guardian/src-foundations/themes';`, - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-react-components' instead.\nThe following export(s) have been renamed [from -> to]: labelDefault -> labelThemeDefault", - }, - ], - output: `import { labelDefault } from '@guardian/source-react-components';`, - }, - { - // Import default - code: `import themes from '@guardian/src-foundations/themes';`, - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-react-components' instead.", - }, - ], - output: `import themes from '@guardian/src-foundations/themes';`, - }, - { - // Import everything - code: `import * as themes from '@guardian/src-foundations/themes';`, - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-react-components' instead.", - }, - ], - output: `import * as themes from '@guardian/src-foundations/themes';`, - }, - { - // Import default, and some named things - code: `import themes, {labelBrand} from '@guardian/src-foundations/themes';`, - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-react-components' instead.\nThe following export(s) have been renamed [from -> to]: labelBrand -> labelThemeBrand", - }, - ], - output: `import themes, {labelBrand} from '@guardian/src-foundations/themes';`, - }, - { - // Export everything from the root of foundations - code: `export * from '@guardian/src-foundations';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Export from '@guardian/source-foundations' instead.`, - }, - ], - output: `export * from '@guardian/src-foundations';`, - }, - { - // Export everything with an alias from the root of foundations - code: `export * as foundations from '@guardian/src-foundations';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Export from '@guardian/source-foundations' instead.`, - }, - ], - output: `export * as foundations from '@guardian/src-foundations';`, - }, - { - // Export everything with an alias from themes - code: `export * from '@guardian/src-foundations/themes';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Export from '@guardian/source-react-components' instead.`, - }, - ], - output: `export * from '@guardian/src-foundations/themes';`, - }, - { - // Export everything from a submodule of foundations - code: `export * from '@guardian/src-foundations/size';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Export from '@guardian/source-foundations' instead.`, - }, - ], - output: `export * from '@guardian/src-foundations/size';`, - }, - { - // Export something that's changed names from foundations - code: `export { headline } from '@guardian/src-foundations/typography/obj';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Export from '@guardian/source-foundations' instead.\nThe following export(s) have been renamed [from -> to]: headline -> headlineObjectStyles`, - }, - ], - output: `export { headline } from '@guardian/source-foundations';`, - }, - { - // Rename theme imports in imports - code: `import { choiceCardDefault } from '@guardian/src-foundations/themes';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Import from '@guardian/source-react-components' instead.\nThe following export(s) have been renamed [from -> to]: choiceCardDefault -> choiceCardThemeDefault`, - }, - ], - output: `import { choiceCardDefault } from '@guardian/source-react-components';`, - }, - { - // Rename theme imports in exports - code: `export { choiceCardDefault } from '@guardian/src-foundations/themes';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Export from '@guardian/source-react-components' instead.\nThe following export(s) have been renamed [from -> to]: choiceCardDefault -> choiceCardThemeDefault`, - }, - ], - output: `export { choiceCardDefault } from '@guardian/source-react-components';`, - }, - { - // Rename and remove theme imports - code: `import { choiceCardDefault, brand } from '@guardian/src-foundations/themes';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Import from '@guardian/source-react-components' instead.\nThe following export(s) have been removed: brand.\nThe following export(s) have been renamed [from -> to]: choiceCardDefault -> choiceCardThemeDefault`, - }, - ], - output: `import { brand } from '@guardian/src-foundations/themes'; -import { choiceCardDefault, } from '@guardian/source-react-components';`, - }, - { - // Rename and remove theme imports regardless of order - code: `import { brand, choiceCardDefault } from '@guardian/src-foundations/themes';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Import from '@guardian/source-react-components' instead.\nThe following export(s) have been removed: brand.\nThe following export(s) have been renamed [from -> to]: choiceCardDefault -> choiceCardThemeDefault`, - }, - ], - output: `import { brand } from '@guardian/src-foundations/themes'; -import { choiceCardDefault } from '@guardian/source-react-components';`, - }, -]; - -ruleTester.run('valid-foundations-import-path', validFoundationsImportPath, { - valid: [ - `import { breakpoints } from '@guardian/source-foundations'`, - `import type { Breakpoint } from '@guardian/source-foundations'`, - ], - invalid: invalidFoundationsCases, -}); diff --git a/libs/@guardian/eslint-plugin-source-foundations/src/rules/valid-import-path.ts b/libs/@guardian/eslint-plugin-source-foundations/src/rules/valid-import-path.ts deleted file mode 100644 index 3026cf6ac..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/src/rules/valid-import-path.ts +++ /dev/null @@ -1,344 +0,0 @@ -import { isUndefined } from '@guardian/libs'; -import type { Rule } from 'eslint'; -import type { - ExportAllDeclaration, - ExportNamedDeclaration, - ExportSpecifier, - ImportDeclaration, - ImportSpecifier, -} from 'estree'; - -type Node = ( - | ImportDeclaration - | ExportNamedDeclaration - | ExportAllDeclaration -) & - Rule.NodeParentExtension; - -type Package = 'foundations' | 'all'; - -const typographyObjChanges = ['body', 'headline', 'textSans', 'titlepiece']; - -const removedImports: Record = { - "'@guardian/source-foundations/utils'": ['InteractionModeEngine'], - "'@guardian/src-foundations/size/global'": ['remSize', 'remIconSize'], - "'@guardian/src-foundations/themes'": ['defaultTheme', 'brand', 'brandAlt'], - "'@guardian/src-helpers'": [ - 'storybookBackgrounds', - 'ThemeName', - 'svgBackgroundImage', - ], -}; - -const newThemeNames: Record = { - accordionDefault: 'accordionThemeDefault', - buttonReaderRevenue: 'buttonThemeReaderRevenue', - buttonReaderRevenueBrand: 'buttonThemeReaderRevenueBrand', - buttonReaderRevenueBrandAlt: 'buttonThemeReaderRevenueBrandAlt', - buttonBrand: 'buttonThemeBrand', - buttonBrandAlt: 'buttonThemeBrandAlt', - buttonDefault: 'buttonThemeDefault', - checkboxBrand: 'checkboxThemeBrand', - checkboxDefault: 'checkboxThemeDefault', - choiceCardDefault: 'choiceCardThemeDefault', - footerBrand: 'footerThemeBrand', - labelDefault: 'labelThemeDefault', - labelBrand: 'labelThemeBrand', - linkBrand: 'linkThemeBrand', - linkBrandAlt: 'linkThemeBrandAlt', - linkDefault: 'linkThemeDefault', - radioBrand: 'radioThemeBrand', - radioDefault: 'radioThemeDefault', - selectDefault: 'selectThemeDefault', - textInputDefault: 'textInputThemeDefault', - userFeedbackBrand: 'userFeedbackThemeBrand', - userFeedbackDefault: 'userFeedbackThemeDefault', -}; - -const capitalise = (str: string): string => - str.charAt(0).toUpperCase() + str.slice(1); - -const getNewPackage = (oldPackage: string): string => { - if (oldPackage === "'@guardian/src-foundations/themes'") { - return "'@guardian/source-react-components'"; - } else if (oldPackage.startsWith("'@guardian/src-foundations")) { - return "'@guardian/source-foundations'"; - } else { - return "'@guardian/source-react-components'"; - } -}; - -const getRemovedExports = ( - node: Node, -): ImportSpecifier[] | ExportSpecifier[] => { - switch (node.type) { - case 'ImportDeclaration': - return node.specifiers.filter((i) => { - const source = node.source.raw; - if (!source || !Object.keys(removedImports).includes(source)) { - return false; - } - - const removedImportsForSource = removedImports[source]; - - if (removedImportsForSource) { - return ( - i.type === 'ImportSpecifier' && - removedImportsForSource.includes(i.imported.name) - ); - } - - return false; - }) as ImportSpecifier[]; - case 'ExportNamedDeclaration': - return node.specifiers.filter((i) => { - const source = node.source?.raw; - if (!source || !Object.keys(removedImports).includes(source)) { - return false; - } - - const removedImportsForSource = removedImports[source]; - if (removedImportsForSource) { - return removedImportsForSource.includes(i.exported.name); - } - - return false; - }); - case 'ExportAllDeclaration': - return []; - } -}; - -const getImportName = (i: ImportSpecifier | ExportSpecifier): string => { - const imported = - i.type === 'ImportSpecifier' ? i.imported.name : i.exported.name; - const local = i.local.name; - - return imported === local ? imported : `${imported} as ${local}`; -}; - -const getSpecifierName = (i: ImportSpecifier | ExportSpecifier): string => { - return i.type === 'ImportSpecifier' ? i.imported.name : i.exported.name; -}; - -const getRenameImportFixers = ( - node: Node, - removedExports: ImportSpecifier[] | ExportSpecifier[], - fixer: Rule.RuleFixer, - nodeSource: string, -): Rule.Fix[] => { - const fixers: Rule.Fix[] = []; - if (!node.source?.raw || node.type === 'ExportAllDeclaration') { - return fixers; - } - - // If anything has been removed then remove it from the fixed import - // Also add a new line which imports the removed exports from the original source - if (removedExports.length) { - for (const i of removedExports) { - if (!i.range) { - break; - } - // Account for a possible comma after the import (e.g. import {one, two} from 'source') - const end = i.range[1]; - const comma = nodeSource.slice(end, end + 1); - fixers.push(fixer.removeRange([i.range[0], comma ? end + 1 : end])); - } - - const importsArray: string[] = []; - - for (const rExport of removedExports) { - const newName = getImportName(rExport); - importsArray.push(newName); - } - - fixers.push( - fixer.insertTextBeforeRange( - node.range ?? [0, 0], - `import { ${importsArray.join(', ')} } from ${node.source.raw};\n`, - ), - ); - } - - return fixers; -}; - -const getMessage = ( - newPackage: string, - removedExports: ImportSpecifier[] | ExportSpecifier[], - node: Node, -): string => { - const importOrExport = node.type.startsWith('Export') ? 'export' : 'import'; - - const newPackageMessage = `@guardian/src-* packages are deprecated. ${capitalise( - importOrExport, - )} from ${newPackage} instead.`; - - if (node.type === 'ExportAllDeclaration') { - return newPackageMessage; - } - - const renamedExports: Array<[string, string]> = []; - - // Some of the typography obj exports have changed name - if (node.source?.raw === "'@guardian/src-foundations/typography/obj'") { - for (const i of node.specifiers) { - if ( - i.type === 'ImportNamespaceSpecifier' || - i.type === 'ImportDefaultSpecifier' - ) { - continue; - } - - const name = getSpecifierName(i); - if (typographyObjChanges.includes(name)) { - renamedExports.push([name, `${name}ObjectStyles`]); - } - } - } - - // Some of the theme exports have changed name - for (const i of node.specifiers) { - if ( - i.type === 'ImportNamespaceSpecifier' || - i.type === 'ImportDefaultSpecifier' - ) { - continue; - } - - const name = getSpecifierName(i); - const newThemeName = newThemeNames[name]; - - if (!isUndefined(newThemeName)) { - renamedExports.push([name, `${newThemeName}`]); - } - } - - let renamedExportsMessage = ''; - if (renamedExports.length) { - renamedExportsMessage = `The following export(s) have been renamed [from -> to]: ${renamedExports - .map(([oldName, newName]) => `${oldName} -> ${newName}`) - .join(', ')}`; - } - - if (!removedExports.length) { - return renamedExportsMessage - ? `${newPackageMessage}\n${renamedExportsMessage}` - : newPackageMessage; - } - - const totalImports = node.specifiers.length; - const removedExportsArray: string[] = []; - - for (const rExport of removedExports) { - removedExportsArray.push( - rExport.type === 'ImportSpecifier' - ? rExport.imported.name - : rExport.exported.name, - ); - } - - const removedExportsMessage = `The following export(s) have been removed: ${removedExportsArray.join( - ', ', - )}.`; - - if (totalImports === removedExports.length) { - return removedExportsMessage; - } else { - return [newPackageMessage, removedExportsMessage, renamedExportsMessage] - .filter((s) => !!s) - .join('\n'); - } -}; - -const relevantImportSource = (importSource: string, pkg: Package): boolean => { - if ( - pkg === 'foundations' && - importSource.startsWith("'@guardian/src-foundations") - ) { - return true; - } - - return pkg === 'all' && importSource.startsWith("'@guardian/src-"); -}; - -const createReport = (context: Rule.RuleContext, node: Node, pkg: Package) => { - const importSource = node.source?.raw; - - if (!importSource || !relevantImportSource(importSource, pkg)) { - return; - } - - const newPackage = getNewPackage(importSource); - - // Check if the export statement is exporting everything - // If so, we won't autofix - if (node.type === 'ExportAllDeclaration') { - return context.report({ - node, - message: getMessage(newPackage, [], node), - }); - } - - // Check if the import statement contains any all or default imports - // If so, we won't autofix - const nonNamedImports = - node.type === 'ImportDeclaration' && - !node.specifiers.every((s) => s.type === 'ImportSpecifier'); - - if (nonNamedImports) { - return context.report({ - node, - message: getMessage(newPackage, [], node), - }); - } - - // Some exports are no longer available from the new packages - // We need to account for these - const removedExports = getRemovedExports(node); - - const nodeSource = context.getSourceCode().getText(node); - - return context.report({ - node, - message: getMessage(newPackage, removedExports, node), - fix: (fixer) => { - // If all of the exports have been removed then don't autofix - return node.specifiers.length === removedExports.length - ? null - : [ - ...getRenameImportFixers(node, removedExports, fixer, nodeSource), - fixer.replaceTextRange(node.source?.range ?? [0, 0], newPackage), - ]; - }, - }); -}; - -export const validFoundationsImportPath: Rule.RuleModule = { - meta: { - type: 'problem', - docs: { - description: 'Get Source imports from v4 packages', - category: 'Deprecated', - url: 'https://github.com/guardian/csnx/tree/main/libs/@guardian/eslint-plugin-source-foundations/README.md', - }, - fixable: 'code', - schema: [], - }, - - create: (context: Rule.RuleContext): Rule.RuleListener => { - return { - ImportDeclaration(node) { - return createReport(context, node, 'foundations'); - }, - ExportNamedDeclaration(node) { - // e.g. export {Props} from '@guardian/src-helpers' - return createReport(context, node, 'foundations'); - }, - ExportAllDeclaration(node) { - // e.g. export * from '@guardian/src-foundations'` - return createReport(context, node, 'foundations'); - }, - }; - }, -}; diff --git a/libs/@guardian/eslint-plugin-source-foundations/tsconfig.json b/libs/@guardian/eslint-plugin-source-foundations/tsconfig.json deleted file mode 100644 index b1aaffb25..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../../tsconfig.base.json", - "files": ["../../../@types/window.d.ts"], - "include": ["."], - "exclude": ["node_modules", "dist", ".wireit"], - "references": [ - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/libs/@guardian/eslint-plugin-source-foundations/tsconfig.spec.json b/libs/@guardian/eslint-plugin-source-foundations/tsconfig.spec.json deleted file mode 100644 index 914db19cb..000000000 --- a/libs/@guardian/eslint-plugin-source-foundations/tsconfig.spec.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "allowJs": true, - "outDir": "../../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": [ - "jest.config.js", - "**/*.test.ts", - "**/*.spec.ts", - "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts" - ] -} diff --git a/libs/@guardian/eslint-plugin-source-react-components/.eslintrc.cjs b/libs/@guardian/eslint-plugin-source-react-components/.eslintrc.cjs deleted file mode 100644 index 846cd70f7..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/.eslintrc.cjs +++ /dev/null @@ -1,39 +0,0 @@ -module.exports = { - extends: ['../../../.eslintrc.cjs'], - ignorePatterns: [ - '!**/*', - 'node_modules', - 'jest.dist.*', // depends on build output, so don't lint it - 'dist', - '.wireit', - ], - overrides: [ - { - files: ['*.ts', '*.tsx'], - parserOptions: { - tsconfigRootDir: __dirname, - }, - rules: {}, - }, - { - files: ['*.ts', '*.tsx'], - rules: {}, - }, - { - files: ['*.js', '*.jsx'], - rules: {}, - }, - { - files: ['*.test.*', 'jest.*'], - env: { - jest: true, - }, - rules: { - '@typescript-eslint/no-unsafe-call': 'off', - '@typescript-eslint/no-unsafe-assignment': 'off', - '@typescript-eslint/restrict-template-expressions': 'off', - '@typescript-eslint/no-unsafe-member-access': 'off', - }, - }, - ], -}; diff --git a/libs/@guardian/eslint-plugin-source-react-components/CHANGELOG.md b/libs/@guardian/eslint-plugin-source-react-components/CHANGELOG.md deleted file mode 100644 index 70043c2d9..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/CHANGELOG.md +++ /dev/null @@ -1,268 +0,0 @@ -# @guardian/eslint-plugin-source-react-components - -## 24.0.1 - -### Patch Changes - -- 0382052: 1. All packages are now ES modules, although they should be compatible with CommonJS environments. 2. Adds entry points for projects that can consume [`package.json#exports`](https://nodejs.org/api/packages.html#exports), alongside `main`. - -## 24.0.0 - -### Major Changes - -- b4b6940: Updated dependencies - - - @guardian/source-react-components@22.0.1 - -## 23.0.0 - -### Major Changes - -- 145ba2a: Updated dependencies - - @guardian/source-foundations@14.1.4 - - @guardian/source-react-components@22.0.0 - -## 22.0.1 - -### Patch Changes - -- a6eb679: Update @typescript-eslint/eslint-plugin and @typescript-eslint/parser - -## 22.0.0 - -### Major Changes - -- 629e941: - Updated dependencies - - @guardian/source-react-components@20.0.0 - -## 21.0.1 - -### Patch Changes - -- 225e542: Dependencies updates: - - - `@typescript-eslint/eslint-plugin` from 6.14.0 to 6.18.0 - - `@typescript-eslint/parser` from 6.14.0 to 6.18.0 - -## 21.0.0 - -### Major Changes - -- Update TS to version 5.3.3 and tslib to 2.6.2 - -- Updated dependencies - - @guardian/source-react-components@18.0.0 - - @guardian/libs@16.0.0 - -## 20.0.1 - -### Patch Changes - -- a116dfe: Update @typescript-eslint/parser and @typescript-eslint/eslint-plugin - -## 20.0.0 - -### Major Changes - -- 9e0cb43: `@typescript-eslint/eslint-plugin` and `@typescript-eslint/parser` dependencies upgraded to next major version (6). - -### Patch Changes - -- Updated dependencies [9e0cb43] - - @guardian/source-react-components@17.0.1 - -## 19.0.0 - -### Major Changes - -- 6bb3297: Updates ESLint to latest version to fix security vulnerability in `word-wrap` dependency - -## 18.0.0 - -### Major Changes - -- Use latest Guardian packages - -## 17.0.0 - -### Major Changes - -- Update Typescript to v5.1.3 and tslib to v2.5.3 - -### Patch Changes - -- Updated dependencies - - @guardian/source-react-components@15.0.0 - - @guardian/libs@15.0.0 - -## 16.0.0 - -### Major Changes - -- Update Source package versions - -## 15.0.0 - -### Major Changes - -- Update React to v18 - -### Patch Changes - -- Updated dependencies - - @guardian/source-react-components@13.0.0 - -## 14.0.0 - -### Major Changes - -- Now requires TypeScript ~4.9.5 (if you use it with TypeScript). - -### Patch Changes - -- Updated dependencies - - @guardian/libs@14.0.0 - - @guardian/source-react-components@12.0.0 - -## 13.0.0 - -### Major Changes - -- 1793e3c: Add linkComponents to settings - - eslint allows us to specify components which should be treated as 'link components' for linting purposes. - In source-react-components, both Link and ButtonLink will apply props directly to an `` tag. Listing them as link components allows rules like `jsx-no-target-blank` to identify them as links, and to lint their props accordingly. - If you don't have any linting rules which look for link elements then this update should not cause any changes. If you do have rules like this then it is possible that new errors or warnings will be raised, but these will be identifying pre-existing issues in your code. - -## 12.0.0 - -### Major Changes - -- c6366dd: Add `tslib@^2.4.1` to peerDependencies - -### Patch Changes - -- Updated dependencies [c6366dd] -- Updated dependencies [b4104c1] -- Updated dependencies [05a5836] - - @guardian/source-react-components@11.0.0 - - @guardian/libs@13.0.0 - -## 11.0.3 - -### Patch Changes - -- 7cd6f21: Bump tslib to v2.4.1 - -## 11.0.2 - -### Patch Changes - -- cf437f9: Bump @guardian/source-foundations to v8 -- Updated dependencies [cf437f9] - - @guardian/source-react-components@10.0.1 - -## 11.0.1 - -### Patch Changes - -- d742b50: Bump @guardian/libs to 12.0.0 - -## 11.0.0 - -### Major Changes - -- eb65fde: Add `typescript@^4.3.2` to `peerDependecies` (`optional`). - - This should mean you get a warning if you're using an incompatible version of typescript, but not if you aren't using it at all. - -### Patch Changes - -- Updated dependencies [eb65fde] - - @guardian/libs@11.0.0 - - @guardian/source-react-components@10.0.0 - -## 10.0.4 - -### Patch Changes - -- 0e11603: Links in `eslint-plugin-source-foundations` and `eslint-plugin-source-react-components` eslint documentation updated to point at the relevant readme instead of the archived Source repo. - -## 10.0.3 - -### Patch Changes - -- a442275: Declare compatability with `@guardian/libs@^10.0.0` - -## 10.0.2 - -### Patch Changes - -- 24ad7d0: Update dependencies - -## 10.0.1 - -### Patch Changes - -- 2033774: No op to test release process - -## 10.0.0 - -### Major Changes - -- aa4c2caa: Bump @guardian/libs to `^9.0.0` - -## 9.0.0 - -### Major Changes - -- Updated `peerDependencies` [905c5148] - - @guardian/source-react-components@9.0.0 - -## 8.0.1 - -### Patch Changes - -- 40e41a43: **No changes**: Patch bump to fix deploy to npm due to the major version already having been published and deleted - -## 8.0.0 - -### Patch Changes - -- @guardian/source-react-components@8.0.0 - -## 7.0.0 - -### Patch Changes - -- Updated dependencies [12a9fce5] -- Updated dependencies [8e8535ba] - - @guardian/source-react-components@7.0.0 - -## 6.0.0 - -### Patch Changes - -- Updated dependencies [07bfaf1b] -- Updated dependencies [78ff24be] -- Updated dependencies [fd69cf60] - - @guardian/source-react-components@6.0.0 - -## 5.0.0 - -### Patch Changes - -- Updated dependencies [b87baf5c] -- Updated dependencies [94a6de68] -- Updated dependencies [1e129d0b] -- Updated dependencies [d55bc4b6] -- Updated dependencies [ef458f83] -- Updated dependencies [a5a14a49] -- Updated dependencies [c37e5be9] - - @guardian/source-react-components@5.0.0 - -## 4.1.0 - -### Minor Changes - -- e6ccc60c: Improve SVG icon accessibility diff --git a/libs/@guardian/eslint-plugin-source-react-components/README.md b/libs/@guardian/eslint-plugin-source-react-components/README.md deleted file mode 100644 index 805cd1df6..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# `@guardian/eslint-plugin-source-react-components` - -> ESLint plugin for Guardian projects using the `@guardian/source-react-components` package. - -This package is part of the [Source design system](/docs/source/README.md). - -## Installation - -```bash -yarn add -D @guardian/eslint-plugin-source-foundations @guardian/eslint-plugin-source-react-components -``` - -or - -```bash -npm install --save-dev @guardian/eslint-plugin-source-foundations @guardian/eslint-plugin-source-react-components -``` - -## Usage - -```js -// ESLint configuration file -{ - "extends": [ - "plugin:@guardian/source-foundations/recommended", - "plugin:@guardian/source-react-components/recommended" - ] -} -``` - -### Valid import path - -This rules errors for imports from a `@guardian/src-*` package. If possible, it will autofix the import to the new location. - -Some breaking changes can not be autofixed, for example, in cases where the export has been removed from Source. Developers must manually provide an alternative. - -### No \* imports or exports - -This rule errors for import or export `*` statements from any `src-*` or `source-*` package as this pattern is not recommended. - -### No duplicate imports - -This rule, from [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import), errors when multiple import statements import from the same pacakge. These issues can be autofixed. This rule is included as, due to the remove of sub modules and the consolidation of component packages, many import statements are fixed by the `valid-import-path` rule to import from the same location in v4. - -## Known Issues - -- New theme names not always updated automatically - - The theme variables have changed both name and location in the v4. The plugin should automatically update both but sometimes this does not work. diff --git a/libs/@guardian/eslint-plugin-source-react-components/jest.config.js b/libs/@guardian/eslint-plugin-source-react-components/jest.config.js deleted file mode 100644 index 8a01fa633..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/jest.config.js +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-disable import/no-default-export -- that's what jest likes */ - -import { config as baseConfig } from '../../../configs/jest.config.js'; - -/** @typedef {import("jest").Config} Config */ -const config = { - ...baseConfig, - displayName: '@guardian/eslint-plugin-source-react-components', - testEnvironment: 'node', -}; - -export default config; diff --git a/libs/@guardian/eslint-plugin-source-react-components/jest.dist.setup.js b/libs/@guardian/eslint-plugin-source-react-components/jest.dist.setup.js deleted file mode 100644 index f17485880..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/jest.dist.setup.js +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable -- this file will break unless the project is built, so let's not worry about it */ - -// Mock `src/index` with whatever the dist `package.json` points at. -// This means we can run `src/index.test.ts` against `dist` instead. - -import * as dist from '.'; - -jest.mock('./src/index', () => dist); diff --git a/libs/@guardian/eslint-plugin-source-react-components/package.json b/libs/@guardian/eslint-plugin-source-react-components/package.json deleted file mode 100644 index 2ccbaabf7..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/package.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "name": "@guardian/eslint-plugin-source-react-components", - "version": "24.0.1", - "description": "ESLint plugin for Guardian projects using the `@guardian/source-react-components` package.", - "type": "module", - "exports": { - "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" - }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "files": [ - "dist" - ], - "scripts": { - "build": "wireit", - "dev": "jest --watch", - "fix": "wireit", - "lint": "wireit", - "test": "wireit", - "verify-dist": "wireit" - }, - "dependencies": { - "@typescript-eslint/eslint-plugin": "6.21.0", - "@typescript-eslint/parser": "6.21.0" - }, - "devDependencies": { - "@emotion/react": "11.11.1", - "@guardian/libs": "16.0.0", - "@guardian/source-foundations": "14.1.4", - "@guardian/source-react-components": "22.0.1", - "@types/eslint": "8.56.1", - "@types/estree": "1.0.5", - "eslint": "8.56.0", - "react": "18.2.0", - "rollup": "4.17.2", - "tslib": "2.6.2", - "typescript": "5.3.3", - "wireit": "0.14.4" - }, - "peerDependencies": { - "@guardian/libs": "^16.0.0", - "@guardian/source-react-components": "^22.0.1", - "@types/eslint": "^8.56.1", - "eslint": "^8.56.0", - "react": "^18.2.0", - "tslib": "^2.6.2", - "typescript": "~5.3.3" - }, - "peerDependenciesMeta": { - "@types/eslint": { - "optional": true - }, - "typescript": { - "optional": true - } - }, - "wireit": { - "build": { - "command": "rollup -c", - "files": [ - "../../../configs/rollup/rollup.config.js", - "./rollup.config.js", - "src/**", - "package.json", - "tsconfig.json" - ], - "output": [ - "dist" - ] - }, - "fix": { - "command": "eslint --cache --color . --fix", - "clean": false, - "files": [ - "!(dist)/**", - "!(.eslintcache)", - "../../../.eslint*" - ], - "output": [ - "." - ] - }, - "lint": { - "command": "eslint --cache --color .", - "files": [ - "!(dist)/**", - "!(.eslintcache)", - "../../../.eslint*" - ], - "output": [] - }, - "test": { - "command": "jest", - "files": [ - "!(dist)/**", - "!(.eslintcache)", - "../../../jest.*" - ], - "output": [] - }, - "verify-dist": { - "command": "jest --setupFilesAfterEnv ./jest.dist.setup.js", - "dependencies": [ - "build" - ], - "files": [ - "!(dist)/**", - "!(.eslintcache)", - "../../../jest.*" - ], - "output": [] - } - } -} diff --git a/libs/@guardian/eslint-plugin-source-react-components/rollup.config.js b/libs/@guardian/eslint-plugin-source-react-components/rollup.config.js deleted file mode 100644 index 93b094d39..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/rollup.config.js +++ /dev/null @@ -1 +0,0 @@ -export * as default from '../../../configs/rollup/rollup.config.js'; diff --git a/libs/@guardian/eslint-plugin-source-react-components/src/index.test.ts b/libs/@guardian/eslint-plugin-source-react-components/src/index.test.ts deleted file mode 100644 index 150fe654e..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/src/index.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as pkgExports from './index'; - -it('Should have exactly these exports', () => { - expect(Object.keys(pkgExports).sort()).toEqual(['configs', 'rules']); -}); diff --git a/libs/@guardian/eslint-plugin-source-react-components/src/index.ts b/libs/@guardian/eslint-plugin-source-react-components/src/index.ts deleted file mode 100644 index 8601db541..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/src/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { validImportPath } from './rules/valid-import-path'; - -export const rules = { - 'valid-import-path': validImportPath, -}; - -export const configs = { - recommended: { - plugins: ['@guardian/source-react-components'], - rules: { - '@guardian/source-react-components/valid-import-path': 'error', - }, - settings: { - linkComponents: [ - // Components used as alternatives to for linking, eg. - { name: 'LinkButton', linkAttribute: 'href' }, - { name: 'Link', linkAttribute: 'href' }, - ], - }, - }, -}; diff --git a/libs/@guardian/eslint-plugin-source-react-components/src/rules/valid-import-path.test.ts b/libs/@guardian/eslint-plugin-source-react-components/src/rules/valid-import-path.test.ts deleted file mode 100644 index e2ade01ab..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/src/rules/valid-import-path.test.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { RuleTester } from 'eslint'; -import { validImportPath } from './valid-import-path'; - -const ruleTester = new RuleTester({ - parser: require.resolve('@typescript-eslint/parser'), - parserOptions: { - ecmaVersion: 2020, - sourceType: 'module', - }, -}); - -ruleTester.run('valid-import-path', validImportPath, { - valid: [ - `import { Label } from '@guardian/source-react-components'`, - `import type { LabelProps } from '@guardian/source-react-components'`, - `import { breakpoints } from '@guardian/source-foundations'`, - `import type { Breakpoint } from '@guardian/source-foundations'`, - ], - invalid: [ - { - // A single component import from a component package - code: "import { Label } from '@guardian/src-label';", - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-react-components' instead.", - }, - ], - output: "import { Label } from '@guardian/source-react-components';", - }, - { - // A single type import from a component package - code: "import type { LabelProps } from '@guardian/src-label';", - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-react-components' instead.", - }, - ], - output: - "import type { LabelProps } from '@guardian/source-react-components';", - }, - { - // Multiple imports from a single package - code: "import { Label, Legend } from '@guardian/src-label';", - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-react-components' instead.", - }, - ], - output: - "import { Label, Legend } from '@guardian/source-react-components';", - }, - { - // Helpers removed exports - code: `import { storybookBackgrounds } from '@guardian/src-helpers';`, - errors: [ - { - message: - 'The following export(s) have been removed: storybookBackgrounds.', - }, - ], - output: `import { storybookBackgrounds } from '@guardian/src-helpers';`, - }, - { - // Helpers moved exports - code: `import type { Props } from '@guardian/src-helpers';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Import from '@guardian/source-react-components' instead.`, - }, - ], - output: `import type { Props } from '@guardian/source-react-components';`, - }, - { - // Export everything from a component - code: `export * from '@guardian/src-button';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Export from '@guardian/source-react-components' instead.`, - }, - ], - output: `export * from '@guardian/src-button';`, - }, - { - // Export everything from helpers - code: `export * from '@guardian/src-helpers';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Export from '@guardian/source-react-components' instead.`, - }, - ], - output: `export * from '@guardian/src-helpers';`, - }, - { - // Export something from helpers - code: `export type { Props } from '@guardian/src-helpers';`, - errors: [ - { - message: `@guardian/src-* packages are deprecated. Export from '@guardian/source-react-components' instead.`, - }, - ], - output: `export type { Props } from '@guardian/source-react-components';`, - }, - { - // Export something that's gone from helpers - code: `export { storybookBackgrounds } from '@guardian/src-helpers';`, - errors: [ - { - message: `The following export(s) have been removed: storybookBackgrounds.`, - }, - ], - output: `export { storybookBackgrounds } from '@guardian/src-helpers';`, - }, - { - // Themes that now come from react-components and have changed names (from component) - code: `import { buttonReaderRevenue } from '@guardian/src-button';`, - errors: [ - { - message: - "@guardian/src-* packages are deprecated. Import from '@guardian/source-react-components' instead.\nThe following export(s) have been renamed [from -> to]: buttonReaderRevenue -> buttonThemeReaderRevenue", - }, - ], - output: `import { buttonReaderRevenue } from '@guardian/source-react-components';`, - }, - ], -}); diff --git a/libs/@guardian/eslint-plugin-source-react-components/src/rules/valid-import-path.ts b/libs/@guardian/eslint-plugin-source-react-components/src/rules/valid-import-path.ts deleted file mode 100644 index eb181fa46..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/src/rules/valid-import-path.ts +++ /dev/null @@ -1,344 +0,0 @@ -import { isUndefined } from '@guardian/libs'; -import type { Rule } from 'eslint'; -import type { - ExportAllDeclaration, - ExportNamedDeclaration, - ExportSpecifier, - ImportDeclaration, - ImportSpecifier, -} from 'estree'; - -type Node = ( - | ImportDeclaration - | ExportNamedDeclaration - | ExportAllDeclaration -) & - Rule.NodeParentExtension; - -type Package = 'foundations' | 'all'; - -const typographyObjChanges = ['body', 'headline', 'textSans', 'titlepiece']; - -const removedImports: Record = { - "'@guardian/source-foundations/utils'": ['InteractionModeEngine'], - "'@guardian/src-foundations/size/global'": ['remSize', 'remIconSize'], - "'@guardian/src-foundations/themes'": ['defaultTheme', 'brand', 'brandAlt'], - "'@guardian/src-helpers'": [ - 'storybookBackgrounds', - 'ThemeName', - 'svgBackgroundImage', - ], -}; - -const newThemeNames: Record = { - accordionDefault: 'accordionThemeDefault', - buttonReaderRevenue: 'buttonThemeReaderRevenue', - buttonReaderRevenueBrand: 'buttonThemeReaderRevenueBrand', - buttonReaderRevenueBrandAlt: 'buttonThemeReaderRevenueBrandAlt', - buttonBrand: 'buttonThemeBrand', - buttonBrandAlt: 'buttonThemeBrandAlt', - buttonDefault: 'buttonThemeDefault', - checkboxBrand: 'checkboxThemeBrand', - checkboxDefault: 'checkboxThemeDefault', - choiceCardDefault: 'choiceCardThemeDefault', - footerBrand: 'footerThemeBrand', - labelDefault: 'labelThemeDefault', - labelBrand: 'labelThemeBrand', - linkBrand: 'linkThemeBrand', - linkBrandAlt: 'linkThemeBrandAlt', - linkDefault: 'linkThemeDefault', - radioBrand: 'radioThemeBrand', - radioDefault: 'radioThemeDefault', - selectDefault: 'selectThemeDefault', - textInputDefault: 'textInputThemeDefault', - userFeedbackBrand: 'userFeedbackThemeBrand', - userFeedbackDefault: 'userFeedbackThemeDefault', -}; - -const capitalise = (str: string): string => - str.charAt(0).toUpperCase() + str.slice(1); - -const getNewPackage = (oldPackage: string): string => { - if (oldPackage === "'@guardian/src-foundations/themes'") { - return "'@guardian/source-react-components'"; - } else if (oldPackage.startsWith("'@guardian/src-foundations")) { - return "'@guardian/source-foundations'"; - } else { - return "'@guardian/source-react-components'"; - } -}; - -const getRemovedExports = ( - node: Node, -): ImportSpecifier[] | ExportSpecifier[] => { - switch (node.type) { - case 'ImportDeclaration': - return node.specifiers.filter((i) => { - const source = node.source.raw; - if (!source || !Object.keys(removedImports).includes(source)) { - return false; - } - - const removedImportsForSource = removedImports[source]; - - if (removedImportsForSource) { - return ( - i.type === 'ImportSpecifier' && - removedImportsForSource.includes(i.imported.name) - ); - } - - return false; - }) as ImportSpecifier[]; - case 'ExportNamedDeclaration': - return node.specifiers.filter((i) => { - const source = node.source?.raw; - if (!source || !Object.keys(removedImports).includes(source)) { - return false; - } - - const removedImportsForSource = removedImports[source]; - if (removedImportsForSource) { - return removedImportsForSource.includes(i.exported.name); - } - - return false; - }); - case 'ExportAllDeclaration': - return []; - } -}; - -const getImportName = (i: ImportSpecifier | ExportSpecifier): string => { - const imported = - i.type === 'ImportSpecifier' ? i.imported.name : i.exported.name; - const local = i.local.name; - - return imported === local ? imported : `${imported} as ${local}`; -}; - -const getSpecifierName = (i: ImportSpecifier | ExportSpecifier): string => { - return i.type === 'ImportSpecifier' ? i.imported.name : i.exported.name; -}; - -const getRenameImportFixers = ( - node: Node, - removedExports: ImportSpecifier[] | ExportSpecifier[], - fixer: Rule.RuleFixer, - nodeSource: string, -): Rule.Fix[] => { - const fixers: Rule.Fix[] = []; - if (!node.source?.raw || node.type === 'ExportAllDeclaration') { - return fixers; - } - - // If anything has been removed then remove it from the fixed import - // Also add a new line which imports the removed exports from the original source - if (removedExports.length) { - for (const i of removedExports) { - if (!i.range) { - break; - } - // Account for a possible comma after the import (e.g. import {one, two} from 'source') - const end = i.range[1]; - const comma = nodeSource.slice(end, end + 1); - fixers.push(fixer.removeRange([i.range[0], comma ? end + 1 : end])); - } - - const importsArray: string[] = []; - - for (const rExport of removedExports) { - const newName = getImportName(rExport); - importsArray.push(newName); - } - - fixers.push( - fixer.insertTextBeforeRange( - node.range ?? [0, 0], - `import { ${importsArray.join(', ')} } from ${node.source.raw};\n`, - ), - ); - } - - return fixers; -}; - -const getMessage = ( - newPackage: string, - removedExports: ImportSpecifier[] | ExportSpecifier[], - node: Node, -): string => { - const importOrExport = node.type.startsWith('Export') ? 'export' : 'import'; - - const newPackageMessage = `@guardian/src-* packages are deprecated. ${capitalise( - importOrExport, - )} from ${newPackage} instead.`; - - if (node.type === 'ExportAllDeclaration') { - return newPackageMessage; - } - - const renamedExports: Array<[string, string]> = []; - - // Some of the typography obj exports have changed name - if (node.source?.raw === "'@guardian/src-foundations/typography/obj'") { - for (const i of node.specifiers) { - if ( - i.type === 'ImportNamespaceSpecifier' || - i.type === 'ImportDefaultSpecifier' - ) { - continue; - } - - const name = getSpecifierName(i); - if (typographyObjChanges.includes(name)) { - renamedExports.push([name, `${name}ObjectStyles`]); - } - } - } - - // Some of the theme exports have changed name - for (const i of node.specifiers) { - if ( - i.type === 'ImportNamespaceSpecifier' || - i.type === 'ImportDefaultSpecifier' - ) { - continue; - } - - const name = getSpecifierName(i); - const newThemeName = newThemeNames[name]; - - if (!isUndefined(newThemeName)) { - renamedExports.push([name, `${newThemeName}`]); - } - } - - let renamedExportsMessage = ''; - if (renamedExports.length) { - renamedExportsMessage = `The following export(s) have been renamed [from -> to]: ${renamedExports - .map(([oldName, newName]) => `${oldName} -> ${newName}`) - .join(', ')}`; - } - - if (!removedExports.length) { - return renamedExportsMessage - ? `${newPackageMessage}\n${renamedExportsMessage}` - : newPackageMessage; - } - - const totalImports = node.specifiers.length; - const removedExportsArray: string[] = []; - - for (const rExport of removedExports) { - removedExportsArray.push( - rExport.type === 'ImportSpecifier' - ? rExport.imported.name - : rExport.exported.name, - ); - } - - const removedExportsMessage = `The following export(s) have been removed: ${removedExportsArray.join( - ', ', - )}.`; - - if (totalImports === removedExports.length) { - return removedExportsMessage; - } else { - return [newPackageMessage, removedExportsMessage, renamedExportsMessage] - .filter((s) => !!s) - .join('\n'); - } -}; - -const relevantImportSource = (importSource: string, pkg: Package): boolean => { - if ( - pkg === 'foundations' && - importSource.startsWith("'@guardian/src-foundations") - ) { - return true; - } - - return pkg === 'all' && importSource.startsWith("'@guardian/src-"); -}; - -const createReport = (context: Rule.RuleContext, node: Node, pkg: Package) => { - const importSource = node.source?.raw; - - if (!importSource || !relevantImportSource(importSource, pkg)) { - return; - } - - const newPackage = getNewPackage(importSource); - - // Check if the export statement is exporting everything - // If so, we won't autofix - if (node.type === 'ExportAllDeclaration') { - return context.report({ - node, - message: getMessage(newPackage, [], node), - }); - } - - // Check if the import statement contains any all or default imports - // If so, we won't autofix - const nonNamedImports = - node.type === 'ImportDeclaration' && - !node.specifiers.every((s) => s.type === 'ImportSpecifier'); - - if (nonNamedImports) { - return context.report({ - node, - message: getMessage(newPackage, [], node), - }); - } - - // Some exports are no longer available from the new packages - // We need to account for these - const removedExports = getRemovedExports(node); - - const nodeSource = context.getSourceCode().getText(node); - - return context.report({ - node, - message: getMessage(newPackage, removedExports, node), - fix: (fixer) => { - // If all of the exports have been removed then don't autofix - return node.specifiers.length === removedExports.length - ? null - : [ - ...getRenameImportFixers(node, removedExports, fixer, nodeSource), - fixer.replaceTextRange(node.source?.range ?? [0, 0], newPackage), - ]; - }, - }); -}; - -export const validImportPath: Rule.RuleModule = { - meta: { - type: 'problem', - docs: { - description: 'Get Source imports from v4 packages', - category: 'Deprecated', - url: 'https://github.com/guardian/csnx/tree/main/libs/@guardian/eslint-plugin-source-react-components/README.md', - }, - fixable: 'code', - schema: [], - }, - - create(context: Rule.RuleContext): Rule.RuleListener { - return { - ImportDeclaration(node) { - return createReport(context, node, 'all'); - }, - ExportNamedDeclaration(node) { - // e.g. export {Props} from '@guardian/src-helpers' - return createReport(context, node, 'all'); - }, - ExportAllDeclaration(node) { - // e.g. export * from '@guardian/src-foundations'` - return createReport(context, node, 'all'); - }, - }; - }, -}; diff --git a/libs/@guardian/eslint-plugin-source-react-components/tsconfig.json b/libs/@guardian/eslint-plugin-source-react-components/tsconfig.json deleted file mode 100644 index b1aaffb25..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../../tsconfig.base.json", - "files": ["../../../@types/window.d.ts"], - "include": ["."], - "exclude": ["node_modules", "dist", ".wireit"], - "references": [ - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/libs/@guardian/eslint-plugin-source-react-components/tsconfig.spec.json b/libs/@guardian/eslint-plugin-source-react-components/tsconfig.spec.json deleted file mode 100644 index 914db19cb..000000000 --- a/libs/@guardian/eslint-plugin-source-react-components/tsconfig.spec.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "allowJs": true, - "outDir": "../../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": [ - "jest.config.js", - "**/*.test.ts", - "**/*.spec.ts", - "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts" - ] -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 882b2c782..7ab3470a4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -408,92 +408,6 @@ importers: specifier: 0.14.4 version: 0.14.4 - libs/@guardian/eslint-plugin-source-foundations: - dependencies: - '@typescript-eslint/eslint-plugin': - specifier: 6.21.0 - version: 6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.56.0)(typescript@5.3.3) - '@typescript-eslint/parser': - specifier: 6.21.0 - version: 6.21.0(eslint@8.56.0)(typescript@5.3.3) - eslint-plugin-import: - specifier: 2.29.1 - version: 2.29.1(@typescript-eslint/parser@6.21.0)(eslint@8.56.0) - devDependencies: - '@guardian/libs': - specifier: 16.0.0 - version: 16.0.0(tslib@2.6.2)(typescript@5.3.3) - '@guardian/source-foundations': - specifier: 14.1.4 - version: 14.1.4(tslib@2.6.2)(typescript@5.3.3) - '@types/eslint': - specifier: 8.56.1 - version: 8.56.1 - '@types/estree': - specifier: 1.0.5 - version: 1.0.5 - eslint: - specifier: 8.56.0 - version: 8.56.0 - rollup: - specifier: 4.17.2 - version: 4.17.2 - tslib: - specifier: 2.6.2 - version: 2.6.2 - typescript: - specifier: 5.3.3 - version: 5.3.3 - wireit: - specifier: 0.14.4 - version: 0.14.4 - - libs/@guardian/eslint-plugin-source-react-components: - dependencies: - '@typescript-eslint/eslint-plugin': - specifier: 6.21.0 - version: 6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.56.0)(typescript@5.3.3) - '@typescript-eslint/parser': - specifier: 6.21.0 - version: 6.21.0(eslint@8.56.0)(typescript@5.3.3) - devDependencies: - '@emotion/react': - specifier: 11.11.1 - version: 11.11.1(@types/react@18.2.11)(react@18.2.0) - '@guardian/libs': - specifier: 16.0.0 - version: 16.0.0(tslib@2.6.2)(typescript@5.3.3) - '@guardian/source-foundations': - specifier: 14.1.4 - version: 14.1.4(tslib@2.6.2)(typescript@5.3.3) - '@guardian/source-react-components': - specifier: 22.0.1 - version: 22.0.1(@emotion/react@11.11.1)(@guardian/source-foundations@14.1.4)(react@18.2.0)(tslib@2.6.2)(typescript@5.3.3) - '@types/eslint': - specifier: 8.56.1 - version: 8.56.1 - '@types/estree': - specifier: 1.0.5 - version: 1.0.5 - eslint: - specifier: 8.56.0 - version: 8.56.0 - react: - specifier: 18.2.0 - version: 18.2.0 - rollup: - specifier: 4.17.2 - version: 4.17.2 - tslib: - specifier: 2.6.2 - version: 2.6.2 - typescript: - specifier: 5.3.3 - version: 5.3.3 - wireit: - specifier: 0.14.4 - version: 0.14.4 - libs/@guardian/identity-auth: devDependencies: '@guardian/libs': @@ -2370,13 +2284,6 @@ packages: regenerator-runtime: 0.14.1 dev: true - /@babel/runtime@7.24.0: - resolution: {integrity: sha512-Chk32uHMg6TnQdvw2e9IlqPpFX/6NLuK0Ys2PqLb7/gL5uFn9mXvK715FGLlOLQrcO4qIkNHkvPGktzzXexsFw==} - engines: {node: '>=6.9.0'} - dependencies: - regenerator-runtime: 0.14.1 - dev: true - /@babel/runtime@7.24.5: resolution: {integrity: sha512-Nms86NXrsaeU9vbBJKni6gXiEXZ4CVpYVzEjDH9Sb8vmZ3UljyA1GSOJl/6LGPO8EHLuSF9H+IxNXHPX8QHJ4g==} engines: {node: '>=6.9.0'} @@ -2450,10 +2357,10 @@ packages: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} dev: true - /@changesets/apply-release-plan@7.0.0: - resolution: {integrity: sha512-vfi69JR416qC9hWmFGSxj7N6wA5J222XNBmezSVATPWDVPIF7gkd4d8CpbEbXmRWbVrkoli3oerGS6dcL/BGsQ==} + /@changesets/apply-release-plan@7.0.1: + resolution: {integrity: sha512-aPdSq/R++HOyfEeBGjEe6LNG8gs0KMSyRETD/J2092OkNq8mOioAxyKjMbvVUdzgr/HTawzMOz7lfw339KnsCA==} dependencies: - '@babel/runtime': 7.24.0 + '@babel/runtime': 7.24.5 '@changesets/config': 3.0.0 '@changesets/get-version-range-type': 0.4.0 '@changesets/git': 3.0.0 @@ -2471,7 +2378,7 @@ packages: /@changesets/assemble-release-plan@6.0.0: resolution: {integrity: sha512-4QG7NuisAjisbW4hkLCmGW2lRYdPrKzro+fCtZaILX+3zdUELSvYjpL4GTv0E4aM9Mef3PuIQp89VmHJ4y2bfw==} dependencies: - '@babel/runtime': 7.24.0 + '@babel/runtime': 7.24.5 '@changesets/errors': 0.2.0 '@changesets/get-dependents-graph': 2.0.0 '@changesets/types': 6.0.0 @@ -2489,8 +2396,8 @@ packages: resolution: {integrity: sha512-iJ91xlvRnnrJnELTp4eJJEOPjgpF3NOh4qeQehM6Ugiz9gJPRZ2t+TsXun6E3AMN4hScZKjqVXl0TX+C7AB3ZQ==} hasBin: true dependencies: - '@babel/runtime': 7.23.6 - '@changesets/apply-release-plan': 7.0.0 + '@babel/runtime': 7.24.5 + '@changesets/apply-release-plan': 7.0.1 '@changesets/assemble-release-plan': 6.0.0 '@changesets/changelog-git': 0.2.0 '@changesets/config': 3.0.0 @@ -2502,25 +2409,25 @@ packages: '@changesets/pre': 2.0.0 '@changesets/read': 0.6.0 '@changesets/types': 6.0.0 - '@changesets/write': 0.3.0 + '@changesets/write': 0.3.1 '@manypkg/get-packages': 1.1.3 - '@types/semver': 7.5.6 + '@types/semver': 7.5.8 ansi-colors: 4.1.3 chalk: 2.4.2 ci-info: 3.9.0 - enquirer: 2.3.6 + enquirer: 2.4.1 external-editor: 3.1.0 fs-extra: 7.0.1 human-id: 1.0.2 meow: 6.1.1 outdent: 0.5.0 p-limit: 2.3.0 - preferred-pm: 3.0.3 + preferred-pm: 3.1.3 resolve-from: 5.0.0 semver: 7.5.4 spawndamnit: 2.0.0 term-size: 2.2.1 - tty-table: 4.1.6 + tty-table: 4.2.3 dev: true /@changesets/config@3.0.0: @@ -2554,7 +2461,7 @@ packages: /@changesets/get-release-plan@4.0.0: resolution: {integrity: sha512-9L9xCUeD/Tb6L/oKmpm8nyzsOzhdNBBbt/ZNcjynbHC07WW4E1eX8NMGC5g5SbM5z/V+MOrYsJ4lRW41GCbg3w==} dependencies: - '@babel/runtime': 7.24.0 + '@babel/runtime': 7.24.5 '@changesets/assemble-release-plan': 6.0.0 '@changesets/config': 3.0.0 '@changesets/pre': 2.0.0 @@ -2570,7 +2477,7 @@ packages: /@changesets/git@3.0.0: resolution: {integrity: sha512-vvhnZDHe2eiBNRFHEgMiGd2CT+164dfYyrJDhwwxTVD/OW0FUD6G7+4DIx1dNwkwjHyzisxGAU96q0sVNBns0w==} dependencies: - '@babel/runtime': 7.24.0 + '@babel/runtime': 7.24.5 '@changesets/errors': 0.2.0 '@changesets/types': 6.0.0 '@manypkg/get-packages': 1.1.3 @@ -2595,7 +2502,7 @@ packages: /@changesets/pre@2.0.0: resolution: {integrity: sha512-HLTNYX/A4jZxc+Sq8D1AMBsv+1qD6rmmJtjsCJa/9MSRybdxh0mjbTvE6JYZQ/ZiQ0mMlDOlGPXTm9KLTU3jyw==} dependencies: - '@babel/runtime': 7.24.0 + '@babel/runtime': 7.24.5 '@changesets/errors': 0.2.0 '@changesets/types': 6.0.0 '@manypkg/get-packages': 1.1.3 @@ -2605,7 +2512,7 @@ packages: /@changesets/read@0.6.0: resolution: {integrity: sha512-ZypqX8+/im1Fm98K4YcZtmLKgjs1kDQ5zHpc2U1qdtNBmZZfo/IBiG162RoP0CUF05tvp2y4IspH11PLnPxuuw==} dependencies: - '@babel/runtime': 7.24.0 + '@babel/runtime': 7.24.5 '@changesets/git': 3.0.0 '@changesets/logger': 0.1.0 '@changesets/parse': 0.4.0 @@ -2623,10 +2530,10 @@ packages: resolution: {integrity: sha512-b1UkfNulgKoWfqyHtzKS5fOZYSJO+77adgL7DLRDr+/7jhChN+QcHnbjiQVOz/U+Ts3PGNySq7diAItzDgugfQ==} dev: true - /@changesets/write@0.3.0: - resolution: {integrity: sha512-slGLb21fxZVUYbyea+94uFiD6ntQW0M2hIKNznFizDhZPDgn2c/fv1UzzlW43RVzh1BEDuIqW6hzlJ1OflNmcw==} + /@changesets/write@0.3.1: + resolution: {integrity: sha512-SyGtMXzH3qFqlHKcvFY2eX+6b0NGiFcNav8AFsYwy5l8hejOeoeTDemu5Yjmke2V5jpzY+pBvM0vCCQ3gdZpfw==} dependencies: - '@babel/runtime': 7.24.0 + '@babel/runtime': 7.24.5 '@changesets/types': 6.0.0 fs-extra: 7.0.1 human-id: 1.0.2 @@ -3312,20 +3219,6 @@ packages: typescript: 5.3.3 dev: true - /@guardian/source-foundations@14.1.4(tslib@2.6.2)(typescript@5.3.3): - resolution: {integrity: sha512-SHkFVBxsE2dSNTKfzmGY1hD9BA7qJ2+bGY1plrUJlYJBCRQdno/YuNummO+wm0Q+kMgxRT0iz5md2DjKYERzQw==} - peerDependencies: - tslib: ^2.6.2 - typescript: ~5.3.3 - peerDependenciesMeta: - typescript: - optional: true - dependencies: - mini-svg-data-uri: 1.4.4 - tslib: 2.6.2 - typescript: 5.3.3 - dev: true - /@guardian/source-foundations@16.0.0(tslib@2.6.2)(typescript@5.3.3): resolution: {integrity: sha512-bdRcJTEJ6tGmibGRwhQcY70NMACHCcsnNsiWRwW1fSPpvcAuR4xvXmn3UlaL1U/RO4Yk1YvJjPiV/n9WHnjbjQ==} peerDependencies: @@ -3340,25 +3233,6 @@ packages: typescript: 5.3.3 dev: true - /@guardian/source-react-components@22.0.1(@emotion/react@11.11.1)(@guardian/source-foundations@14.1.4)(react@18.2.0)(tslib@2.6.2)(typescript@5.3.3): - resolution: {integrity: sha512-jpnFdc/fIRQswufgFDjlv0RQvtNpWd5PL7PJa4r7oNp8H8f+LEVn1D/WkuLFQwtP+T3S/wGF5GrcOmTMyFTlYA==} - peerDependencies: - '@emotion/react': ^11.11.1 - '@guardian/source-foundations': ^14.1.4 - react: ^18.2.0 - tslib: ^2.6.2 - typescript: ~5.3.3 - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@emotion/react': 11.11.1(@types/react@18.2.11)(react@18.2.0) - '@guardian/source-foundations': 14.1.4(tslib@2.6.2)(typescript@5.3.3) - react: 18.2.0 - tslib: 2.6.2 - typescript: 5.3.3 - dev: true - /@guardian/source-react-components@25.0.0(@emotion/react@11.11.1)(@guardian/source-foundations@16.0.0)(@types/react@18.2.11)(react@18.2.0)(tslib@2.6.2)(typescript@5.3.3): resolution: {integrity: sha512-9llnT6DUiLmdhklciMO75SBC9DbBqLw+jBWxhu60J+uAyw7B2WqG9Bmk8wPBCSrRe4hNvsosJyVMI+KiRb48Bw==} peerDependencies: @@ -3706,7 +3580,7 @@ packages: /@manypkg/get-packages@1.1.3: resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==} dependencies: - '@babel/runtime': 7.24.0 + '@babel/runtime': 7.24.5 '@changesets/types': 4.1.0 '@manypkg/find-root': 1.1.0 fs-extra: 8.1.0 @@ -5280,13 +5154,6 @@ packages: '@types/eslint': 8.56.6 '@types/estree': 1.0.5 - /@types/eslint@8.56.1: - resolution: {integrity: sha512-18PLWRzhy9glDQp3+wOgfLYRWlhgX0azxgJ63rdpoUHyrC9z0f5CkFburjQx4uD7ZCruw85ZtMt6K+L+R8fLJQ==} - dependencies: - '@types/estree': 1.0.5 - '@types/json-schema': 7.0.15 - dev: true - /@types/eslint@8.56.6: resolution: {integrity: sha512-ymwc+qb1XkjT/gfoQwxIeHZ6ixH23A+tCT2ADSA/DPVKzAjwYkTXBMCQ/f6fe4wEa85Lhp26VPeUxI7wMhAi7A==} dependencies: @@ -5390,8 +5257,8 @@ packages: /@types/mime@3.0.4: resolution: {integrity: sha512-iJt33IQnVRkqeqC7PzBHPTC6fDlRNRW8vjrgqtScAhrmMwe8c4Eo7+fUGTa+XdWrpEgpyKWMYmi2dIwMAYRzPw==} - /@types/minimist@1.2.2: - resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} + /@types/minimist@1.2.5: + resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==} dev: true /@types/mkdirp@2.0.0: @@ -5476,10 +5343,6 @@ packages: /@types/scheduler@0.16.8: resolution: {integrity: sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==} - /@types/semver@7.5.6: - resolution: {integrity: sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==} - dev: true - /@types/semver@7.5.8: resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} @@ -5570,10 +5433,11 @@ packages: ignore: 5.3.1 natural-compare: 1.4.0 semver: 7.5.4 - ts-api-utils: 1.2.0(typescript@5.3.3) + ts-api-utils: 1.3.0(typescript@5.3.3) typescript: 5.3.3 transitivePeerDependencies: - supports-color + dev: true /@typescript-eslint/eslint-plugin@7.3.1(@typescript-eslint/parser@7.3.1)(eslint@8.56.0)(typescript@5.3.3): resolution: {integrity: sha512-STEDMVQGww5lhCuNXVSQfbfuNII5E08QWkvAw5Qwf+bj2WT+JkG1uc+5/vXA3AOYMDHVOSpL+9rcbEUiHIm2dw==} @@ -5690,10 +5554,11 @@ packages: '@typescript-eslint/utils': 6.21.0(eslint@8.56.0)(typescript@5.3.3) debug: 4.3.4(supports-color@8.1.1) eslint: 8.56.0 - ts-api-utils: 1.2.0(typescript@5.3.3) + ts-api-utils: 1.3.0(typescript@5.3.3) typescript: 5.3.3 transitivePeerDependencies: - supports-color + dev: true /@typescript-eslint/type-utils@7.3.1(eslint@8.56.0)(typescript@5.3.3): resolution: {integrity: sha512-iFhaysxFsMDQlzJn+vr3OrxN8NmdQkHks4WaqD4QBnt5hsq234wcYdyQ9uquzJJIDAj5W4wQne3yEsYA6OmXGw==} @@ -5768,7 +5633,7 @@ packages: is-glob: 4.0.3 minimatch: 9.0.3 semver: 7.5.4 - ts-api-utils: 1.2.0(typescript@5.3.3) + ts-api-utils: 1.3.0(typescript@5.3.3) typescript: 5.3.3 transitivePeerDependencies: - supports-color @@ -5838,6 +5703,7 @@ packages: transitivePeerDependencies: - supports-color - typescript + dev: true /@typescript-eslint/utils@7.3.1(eslint@8.56.0)(typescript@5.3.3): resolution: {integrity: sha512-jIERm/6bYQ9HkynYlNZvXpzmXWZGhMbrOvq3jJzOSOlKXsVjrrolzWBjDW6/TvT5Q3WqaN4EkmcfdQwi9tDjBQ==} @@ -6844,8 +6710,8 @@ packages: dependencies: fill-range: 7.0.1 - /breakword@1.0.5: - resolution: {integrity: sha512-ex5W9DoOQ/LUEU3PMdLs9ua/CYZl1678NUkKOdUSi8Aw5F1idieaiRURCBFJCwVcrD1J8Iy3vfWSloaMwO2qFg==} + /breakword@1.0.6: + resolution: {integrity: sha512-yjxDAYyK/pBvws9H4xKYpLDpYKEH6CzrBPAuXq3x18I+c/2MkVtT3qAr7Oloi6Dss9qNhPVueAAVU1CSeNDIXw==} dependencies: wcwidth: 1.0.1 dev: true @@ -8113,13 +7979,6 @@ packages: graceful-fs: 4.2.11 tapable: 2.2.1 - /enquirer@2.3.6: - resolution: {integrity: sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==} - engines: {node: '>=8.6'} - dependencies: - ansi-colors: 4.1.3 - dev: true - /enquirer@2.4.1: resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} engines: {node: '>=8.6'} @@ -8479,7 +8338,7 @@ packages: dependencies: escape-string-regexp: 1.0.5 eslint: 8.56.0 - ignore: 5.2.1 + ignore: 5.3.1 /eslint-plugin-import@2.29.0(@typescript-eslint/parser@6.21.0)(eslint@8.56.0): resolution: {integrity: sha512-QPOO5NO6Odv5lpoTkddtutccQjysJuFxoPS7fAHO+9m9udNHvTCPSAMW9zGAYj8lAIdr40I8yPCdUYrncXtrwg==} @@ -8503,7 +8362,7 @@ packages: eslint: 8.56.0 eslint-import-resolver-node: 0.3.9 eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.21.0)(eslint-import-resolver-node@0.3.9)(eslint@8.56.0) - hasown: 2.0.0 + hasown: 2.0.2 is-core-module: 2.13.1 is-glob: 4.0.3 minimatch: 3.1.2 @@ -8511,7 +8370,7 @@ packages: object.groupby: 1.0.1 object.values: 1.1.7 semver: 6.3.1 - tsconfig-paths: 3.14.2 + tsconfig-paths: 3.15.0 transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack @@ -9535,6 +9394,7 @@ packages: engines: {node: '>= 0.4'} dependencies: function-bind: 1.1.2 + dev: false /hasown@2.0.2: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} @@ -9851,10 +9711,6 @@ packages: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} dev: true - /ignore@5.2.1: - resolution: {integrity: sha512-d2qQLzTJ9WxQftPAuEQpSPmKqzxePjzVbpAVv62AQ64NTL+wR4JkrVqR/LqFsFEUsHDAiId52mJteHDFuDkElA==} - engines: {node: '>= 4'} - /ignore@5.3.1: resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==} engines: {node: '>= 4'} @@ -10515,7 +10371,7 @@ packages: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 '@types/jsdom': 20.0.1 - '@types/node': 18.19.3 + '@types/node': 20.12.11 jest-mock: 29.7.0 jest-util: 29.7.0 jsdom: 20.0.3 @@ -11582,7 +11438,7 @@ packages: resolution: {integrity: sha512-3YffViIt2QWgTy6Pale5QpopX/IvU3LPL03jOTqp6pGj3VjesdO/U8CuHMKpnQr4shCNCM5fd5XFFvIIl6JBHg==} engines: {node: '>=8'} dependencies: - '@types/minimist': 1.2.2 + '@types/minimist': 1.2.5 camelcase-keys: 6.2.2 decamelize-keys: 1.1.1 hard-rejection: 2.1.0 @@ -11968,8 +11824,8 @@ packages: yallist: 4.0.0 dev: true - /mixme@0.5.4: - resolution: {integrity: sha512-3KYa4m4Vlqx98GPdOHghxSdNtTvcP8E0kkaJ5Dlh+h2DRzF7zpuVVcA8B0QpKd11YJeP9QQ7ASkKzOeu195Wzw==} + /mixme@0.5.10: + resolution: {integrity: sha512-5H76ANWinB1H3twpJ6JY8uvAtpmFvHNArpilJAjXRKXSDDLPIMoZArw5SH0q9z+lLs8IrMw7Q2VWpWimFKFT1Q==} engines: {node: '>= 8.0.0'} dev: true @@ -12707,16 +12563,6 @@ packages: dev: true optional: true - /preferred-pm@3.0.3: - resolution: {integrity: sha512-+wZgbxNES/KlJs9q40F/1sfOd/j7f1O9JaHcW5Dsn3aUUOZg3L2bjpVUcKV2jvtElYfoTuQiNeMfQJ4kwUAhCQ==} - engines: {node: '>=10'} - dependencies: - find-up: 5.0.0 - find-yarn-workspace-root2: 1.2.16 - path-exists: 4.0.0 - which-pm: 2.0.0 - dev: true - /preferred-pm@3.1.3: resolution: {integrity: sha512-MkXsENfftWSRpzCzImcp4FRsCc3y1opwB73CfCNWyzMqArju2CrlMHlqB7VexKiPEOjGMbttv1r9fSCn5S610w==} engines: {node: '>=10'} @@ -13777,7 +13623,7 @@ packages: hasBin: true dependencies: array.prototype.flat: 1.3.2 - breakword: 1.0.5 + breakword: 1.0.6 grapheme-splitter: 1.0.4 strip-ansi: 6.0.1 wcwidth: 1.0.1 @@ -13936,7 +13782,7 @@ packages: /stream-transform@2.1.3: resolution: {integrity: sha512-9GHUiM5hMiCi6Y03jD2ARC1ettBXkQBoQAe7nJsPknnI0ow10aXjTnew8QtYQmLjzn974BnmWEAJgCY6ZP1DeQ==} dependencies: - mixme: 0.5.4 + mixme: 0.5.10 dev: true /streamx@2.16.1: @@ -14450,6 +14296,7 @@ packages: typescript: '>=4.2.0' dependencies: typescript: 5.3.3 + dev: false /ts-api-utils@1.3.0(typescript@5.3.3): resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==} @@ -14458,7 +14305,6 @@ packages: typescript: '>=4.2.0' dependencies: typescript: 5.3.3 - dev: false /ts-dedent@2.2.0: resolution: {integrity: sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==} @@ -14546,15 +14392,6 @@ packages: typescript: 5.3.3 dev: true - /tsconfig-paths@3.14.2: - resolution: {integrity: sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==} - dependencies: - '@types/json5': 0.0.29 - json5: 1.0.2 - minimist: 1.2.8 - strip-bom: 3.0.0 - dev: true - /tsconfig-paths@3.15.0: resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} dependencies: @@ -14562,7 +14399,6 @@ packages: json5: 1.0.2 minimist: 1.2.8 strip-bom: 3.0.0 - dev: false /tsconfig-paths@4.2.0: resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==} @@ -14600,8 +14436,8 @@ packages: fsevents: 2.3.3 dev: true - /tty-table@4.1.6: - resolution: {integrity: sha512-kRj5CBzOrakV4VRRY5kUWbNYvo/FpOsz65DzI5op9P+cHov3+IqPbo1JE1ZnQGkHdZgNFDsrEjrfqqy/Ply9fw==} + /tty-table@4.2.3: + resolution: {integrity: sha512-Fs15mu0vGzCrj8fmJNP7Ynxt5J7praPXqFN0leZeZBXJwkMxv9cb2D454k1ltrtUSJbZ4yH4e0CynsHLxmUfFA==} engines: {node: '>=8.0.0'} hasBin: true dependencies: @@ -15500,8 +15336,8 @@ packages: is-weakset: 2.0.2 dev: true - /which-module@2.0.0: - resolution: {integrity: sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==} + /which-module@2.0.1: + resolution: {integrity: sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==} dev: true /which-pm-runs@1.1.0: @@ -15710,7 +15546,7 @@ packages: require-main-filename: 2.0.0 set-blocking: 2.0.0 string-width: 4.2.3 - which-module: 2.0.0 + which-module: 2.0.1 y18n: 4.0.3 yargs-parser: 18.1.3 dev: true From a35e7a973b3aa299acec8b6471b5e4375ea5bd3e Mon Sep 17 00:00:00 2001 From: Alex Sanders Date: Thu, 23 May 2024 09:59:13 +0100 Subject: [PATCH 2/2] remove refs to the plugins --- .github/CODEOWNERS | 2 -- docs/source/README.md | 5 ----- 2 files changed, 7 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 91e27fb19..77b293f42 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -13,8 +13,6 @@ /libs/@guardian/source-foundations/ @guardian/client-side-infra @guardian/source /libs/@guardian/source-react-components/ @guardian/client-side-infra @guardian/source /libs/@guardian/source-react-components-development-kitchen/ @guardian/client-side-infra @guardian/source -/libs/@guardian/eslint-plugin-source-foundations/ @guardian/client-side-infra @guardian/source -/libs/@guardian/eslint-plugin-source-react-components/ @guardian/client-side-infra @guardian/source /libs/@guardian/browserlist-config/ @guardian/client-side-infra @guardian/dotcom-platform diff --git a/docs/source/README.md b/docs/source/README.md index f174a68fd..a02524918 100644 --- a/docs/source/README.md +++ b/docs/source/README.md @@ -12,11 +12,6 @@ There are three main Source packages: - [`@guardian/source-react-components`](../../libs/@guardian/source-react-components/README.md): A set of robust, accessible React components built using @guardian/source-foundations - [`@guardian/source-react-components-development-kitchen`](../../libs/@guardian/source-react-components-development-kitchen/README.md): The Development Kitchen is where new components and patterns can be cooked up, tested and shared. There are minimal acceptance criteria. It’s okay to duplicate and break things. If a Kitchen component proves valuable, it may be promoted to `@guardian/source-react-components` -In addition there are two ESLint plugins: - -- [`@guardian/eslint-plugin-source-foundations`](../../libs/@guardian/eslint-plugin-source-foundations/README.md): ESLint plugin for Guardian projects using the `@guardian/source-foundations` package -- [`@guardian/eslint-plugin-source-react-components`](../../libs/@guardian/eslint-plugin-source-react-components/README.md): ESLint plugin for Guardian projects using the `@guardian/source-react-components` package - ## Contributing We welcome contributions to Source! See our [contributing](contributing.md) and [Storybook](storybook.md) docs for more info.