Skip to content

Commit

Permalink
Generate relative links in docs script, remove unnecessary npm link
Browse files Browse the repository at this point in the history
  • Loading branch information
matejchalk committed Dec 2, 2024
1 parent efcf27f commit 9c4b5aa
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 59 deletions.
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ Recommended ESLint presets by [Code PushUp](https://github.com/code-pushup/cli/t

## ⚙️ Configs

| Stack | Config | Description |
| :----------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------- | :------------------------------------------------------------------ |
| ![javascript](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/javascript.png) | [javascript](https://github.com/code-pushup/eslint-config/blob/main/docs/javascript.md) | Default config, suitable for any **JavaScript/TypeScript** project. |
| ![typescript](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/typescript.png) | [typescript](https://github.com/code-pushup/eslint-config/blob/main/docs/typescript.md) | Config for strict **TypeScript** projects. |
| ![nodejs](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/nodejs.png) | [node](https://github.com/code-pushup/eslint-config/blob/main/docs/node.md) | Config for **Node.js** projects. |
| ![angular](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/angular.png) | [angular](https://github.com/code-pushup/eslint-config/blob/main/docs/angular.md) | Config for **Angular** projects. |
| ![ngrx](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/other/ngrx.png) | [ngrx](https://github.com/code-pushup/eslint-config/blob/main/docs/ngrx.md) | Config for **Angular** projects using **NgRx** library. |
| ![graphql](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/graphql.png) | [graphql](https://github.com/code-pushup/eslint-config/blob/main/docs/graphql.md) | Config for **GraphQL servers** implemented in Node.js. |
| ![jest](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/jest.png) | [jest](https://github.com/code-pushup/eslint-config/blob/main/docs/jest.md) | Config for projects using **Jest** for testing. |
| ![vitest](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/vitest.png) | [vitest](https://github.com/code-pushup/eslint-config/blob/main/docs/vitest.md) | Config for projects using **Vitest** for testing. |
| ![cypress](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/cypress.png) | [cypress](https://github.com/code-pushup/eslint-config/blob/main/docs/cypress.md) | Config for projects using **Cypress** for testing. |
| ![storybook](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/storybook.png) | [storybook](https://github.com/code-pushup/eslint-config/blob/main/docs/storybook.md) | Config for projects using **Storybook** for UI components. |
| Stack | Config | Description |
| :-------------------------------------------------: | :--------------------------------- | :------------------------------------------------------------------ |
| ![javascript](./docs/icons/material/javascript.png) | [javascript](./docs/javascript.md) | Default config, suitable for any **JavaScript/TypeScript** project. |
| ![typescript](./docs/icons/material/typescript.png) | [typescript](./docs/typescript.md) | Config for strict **TypeScript** projects. |
| ![nodejs](./docs/icons/material/nodejs.png) | [node](./docs/node.md) | Config for **Node.js** projects. |
| ![angular](./docs/icons/material/angular.png) | [angular](./docs/angular.md) | Config for **Angular** projects. |
| ![ngrx](./docs/icons/other/ngrx.png) | [ngrx](./docs/ngrx.md) | Config for **Angular** projects using **NgRx** library. |
| ![graphql](./docs/icons/material/graphql.png) | [graphql](./docs/graphql.md) | Config for **GraphQL servers** implemented in Node.js. |
| ![jest](./docs/icons/material/jest.png) | [jest](./docs/jest.md) | Config for projects using **Jest** for testing. |
| ![vitest](./docs/icons/material/vitest.png) | [vitest](./docs/vitest.md) | Config for projects using **Vitest** for testing. |
| ![cypress](./docs/icons/material/cypress.png) | [cypress](./docs/cypress.md) | Config for projects using **Cypress** for testing. |
| ![storybook](./docs/icons/material/storybook.png) | [storybook](./docs/storybook.md) | Config for projects using **Storybook** for UI components. |

Some configs extend other configs, as illustrated below. So, for example, extending `angular` config implicitly extends `typescript` and `javascript` configs as well.

Expand Down Expand Up @@ -70,28 +70,28 @@ Depending on your tech stack, you may wish to extend other configs as well ([lis

All peer dependencies used by `@code-pushup/eslint-config` are listed below, along with their supported versions. Only the default config's dependencies are required, others are optional.

| | NPM package | Version | Required |
| :----------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------- | :--------: | :------: |
| ![eslint](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/eslint.png) | [eslint](https://www.npmjs.com/package/eslint) | `^9.0.0` ||
| ![eslint](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/eslint.png) | [@eslint/js](https://www.npmjs.com/package/@eslint/js) | `^9.0.0` ||
| ![lambda](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/icons8/lambda.png) | [eslint-plugin-functional](https://www.npmjs.com/package/eslint-plugin-functional) | `^7.0.0` ||
| ![import](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/icons8/import.png) | [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import) | `^2.31.0` ||
| ![import](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/icons8/import.png) | [eslint-import-resolver-typescript](https://www.npmjs.com/package/eslint-import-resolver-typescript) | `^3.0.0` | |
| ![promise](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/icons8/promise.png) | [eslint-plugin-promise](https://www.npmjs.com/package/eslint-plugin-promise) | `>=6.4.0` ||
| ![sonar](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/other/sonar.png) | [eslint-plugin-sonarjs](https://www.npmjs.com/package/eslint-plugin-sonarjs) | `>=1.0.4` ||
| ![unicorn](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/icons8/unicorn.png) | [eslint-plugin-unicorn](https://www.npmjs.com/package/eslint-plugin-unicorn) | `>=50.0.0` ||
| ![global](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/icons8/global.png) | [globals](https://www.npmjs.com/package/globals) | `>=14.0.0` ||
| ![typescript](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/typescript.png) | [typescript-eslint](https://www.npmjs.com/package/typescript-eslint) | `^8.0.0` ||
| ![graphql](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/graphql.png) | [@graphql-eslint/eslint-plugin](https://www.npmjs.com/package/@graphql-eslint/eslint-plugin) | `^3.0.0` | |
| ![ngrx](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/other/ngrx.png) | [@ngrx/eslint-plugin](https://www.npmjs.com/package/@ngrx/eslint-plugin) | `^18.0.0` | |
| ![angular](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/angular.png) | [angular-eslint](https://www.npmjs.com/package/angular-eslint) | `^18.0.0` | |
| ![cypress](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/cypress.png) | [eslint-plugin-cypress](https://www.npmjs.com/package/eslint-plugin-cypress) | `>=3.3.0` | |
| ![jest](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/jest.png) | [eslint-plugin-jest](https://www.npmjs.com/package/eslint-plugin-jest) | `^28.8.0` | |
| ![test](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/icons8/test.png) | [eslint-plugin-jest-formatting](https://www.npmjs.com/package/eslint-plugin-jest-formatting) | `^3.0.0` | |
| ![nodejs](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/nodejs.png) | [eslint-plugin-n](https://www.npmjs.com/package/eslint-plugin-n) | `>=17.0.0` | |
| ![rxjs](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/other/rxjs.png) | [eslint-plugin-rxjs-x](https://www.npmjs.com/package/eslint-plugin-rxjs-x) | `>=0.2.4` | |
| ![storybook](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/storybook.png) | [eslint-plugin-storybook](https://www.npmjs.com/package/eslint-plugin-storybook) | `>=0.10.0` | |
| ![vitest](https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/material/vitest.png) | [eslint-plugin-vitest](https://www.npmjs.com/package/eslint-plugin-vitest) | `>=0.5.0` | |
| | NPM package | Version | Required |
| :-------------------------------------------------: | :--------------------------------------------------------------------------------------------------- | :--------: | :------: |
| ![eslint](./docs/icons/material/eslint.png) | [eslint](https://www.npmjs.com/package/eslint) | `^9.0.0` ||
| ![eslint](./docs/icons/material/eslint.png) | [@eslint/js](https://www.npmjs.com/package/@eslint/js) | `^9.0.0` ||
| ![lambda](./docs/icons/icons8/lambda.png) | [eslint-plugin-functional](https://www.npmjs.com/package/eslint-plugin-functional) | `^7.0.0` ||
| ![import](./docs/icons/icons8/import.png) | [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import) | `^2.31.0` ||
| ![import](./docs/icons/icons8/import.png) | [eslint-import-resolver-typescript](https://www.npmjs.com/package/eslint-import-resolver-typescript) | `^3.0.0` | |
| ![promise](./docs/icons/icons8/promise.png) | [eslint-plugin-promise](https://www.npmjs.com/package/eslint-plugin-promise) | `>=6.4.0` ||
| ![sonar](./docs/icons/other/sonar.png) | [eslint-plugin-sonarjs](https://www.npmjs.com/package/eslint-plugin-sonarjs) | `>=1.0.4` ||
| ![unicorn](./docs/icons/icons8/unicorn.png) | [eslint-plugin-unicorn](https://www.npmjs.com/package/eslint-plugin-unicorn) | `>=50.0.0` ||
| ![global](./docs/icons/icons8/global.png) | [globals](https://www.npmjs.com/package/globals) | `>=14.0.0` ||
| ![typescript](./docs/icons/material/typescript.png) | [typescript-eslint](https://www.npmjs.com/package/typescript-eslint) | `^8.0.0` ||
| ![graphql](./docs/icons/material/graphql.png) | [@graphql-eslint/eslint-plugin](https://www.npmjs.com/package/@graphql-eslint/eslint-plugin) | `^3.0.0` | |
| ![ngrx](./docs/icons/other/ngrx.png) | [@ngrx/eslint-plugin](https://www.npmjs.com/package/@ngrx/eslint-plugin) | `^18.0.0` | |
| ![angular](./docs/icons/material/angular.png) | [angular-eslint](https://www.npmjs.com/package/angular-eslint) | `^18.0.0` | |
| ![cypress](./docs/icons/material/cypress.png) | [eslint-plugin-cypress](https://www.npmjs.com/package/eslint-plugin-cypress) | `>=3.3.0` | |
| ![jest](./docs/icons/material/jest.png) | [eslint-plugin-jest](https://www.npmjs.com/package/eslint-plugin-jest) | `^28.8.0` | |
| ![test](./docs/icons/icons8/test.png) | [eslint-plugin-jest-formatting](https://www.npmjs.com/package/eslint-plugin-jest-formatting) | `^3.0.0` | |
| ![nodejs](./docs/icons/material/nodejs.png) | [eslint-plugin-n](https://www.npmjs.com/package/eslint-plugin-n) | `>=17.0.0` | |
| ![rxjs](./docs/icons/other/rxjs.png) | [eslint-plugin-rxjs-x](https://www.npmjs.com/package/eslint-plugin-rxjs-x) | `>=0.2.4` | |
| ![storybook](./docs/icons/material/storybook.png) | [eslint-plugin-storybook](https://www.npmjs.com/package/eslint-plugin-storybook) | `>=0.10.0` | |
| ![vitest](./docs/icons/material/vitest.png) | [eslint-plugin-vitest](https://www.npmjs.com/package/eslint-plugin-vitest) | `>=0.5.0` | |

### 🧪 Test overrides

Expand Down
22 changes: 7 additions & 15 deletions scripts/docs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-check

import { ESLint } from 'eslint';
import { execSync } from 'node:child_process';
import fs from 'node:fs/promises';
import path, { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
Expand All @@ -27,23 +26,16 @@ const docsDir = path.join(currentDir, '..', 'docs');
await generateDocs();

async function generateDocs() {
execSync('npm link');
execSync('npm link @code-pushup/eslint-config');
const configs = await loadConfigs(configNames);
const peerDeps = await loadPeerDependencies(configs);

try {
const configs = await loadConfigs(configNames);
const peerDeps = await loadPeerDependencies(configs);
await fs.mkdir(docsDir, { recursive: true });

await fs.mkdir(docsDir, { recursive: true });

for (const config of configs) {
await generateConfigDocs(config, configs, peerDeps);
}

await generateReadmeDocs(configs, peerDeps);
} finally {
execSync('npm unlink @code-pushup/eslint-config');
for (const config of configs) {
await generateConfigDocs(config, configs, peerDeps);
}

await generateReadmeDocs(configs, peerDeps);
}

/**
Expand Down
10 changes: 2 additions & 8 deletions scripts/helpers/format-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ export function configsToMarkdown(configs, peerDeps, extended) {
],
configs.map(config => [
iconToImage(configIcon(config)),
md.link(
`https://github.com/code-pushup/eslint-config/blob/main/docs/${config}.md`,
config,
),
md.link(`./docs/${config}.md`, config),
configDescription(config),
]),
)
Expand Down Expand Up @@ -117,10 +114,7 @@ export function configsToMarkdown(configs, peerDeps, extended) {

/** @param {import('./types').Icon} icon */
function iconToImage(icon) {
return md.image(
`https://raw.githubusercontent.com/code-pushup/eslint-config/main/docs/icons/${icon}.png`,
icon.replace(/^\w+\//, ''),
);
return md.image(`./docs/icons/${icon}.png`, icon.replace(/^\w+\//, ''));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/lint-utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @ts-check

import { ESLint } from 'eslint';
const fs = require('node:fs/promises');
const path = require('node:path');
import fs from 'node:fs/promises';
import path from 'node:path';

/**
* Sets up utilities for loading configuration and rules using ESLint
Expand Down

0 comments on commit 9c4b5aa

Please sign in to comment.