Skip to content

Commit

Permalink
refactor: rename and move eslint-utils (#1229)
Browse files Browse the repository at this point in the history
  • Loading branch information
noshiro-pf authored Jul 10, 2024
1 parent 10df697 commit 98b805b
Show file tree
Hide file tree
Showing 215 changed files with 298 additions and 985 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ $ yarn ws:build
- tsconfig
- 各 workspace で継承する共通 tsconfig 定義を置いている。
- 特殊 utility の説明
- `packages/utils/eslint-utils`
- `packages/eslint-configs`
- eslint 共通設定を定義している。
- ESModule で記述するために flat config を導入(2023/11)
- TypeScript で記述している
- `yarn workspace @noshiro/eslint-utils build` により生成(その後一部手動修正が必要)
- `yarn workspace @noshiro/eslint-configs build` により生成(その後一部手動修正が必要)
- `plugin:@typescript-eslint:recommended` 等の public な config は使っておらず、 rule の設定を明示的に記述している。
- 主に多数の config を extends に追加した際のルール設定の上書き結果が曖昧になる問題を避けるため。各ルールはちょうど 1 回ずつ定義されている状態になっている。
- `@typescript-eslint` のルールに対応する `eslint` のルールや `prettier` と競合するルール無効化が必要な場合があるが、これらは適宜 plugin の提供している config を参考に手動で設定している。
Expand Down
2 changes: 1 addition & 1 deletion articles/take-full-advantage-of-typescript-eslint.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ plugin ごとに全ルールを逐一設定していく作業が mono repo な

最近 eslint のより新しい config スタイルである [Flat Config](https://eslint.org/docs/latest/use/configure/configuration-files-new) を採用した上で、 config ファイル記述にも TypeScript を使用する状態に移行しつつあります。

https://github.com/noshiro-pf/mono/blob/develop/packages/utils/eslint-utils
https://github.com/noshiro-pf/mono/blob/develop/packages/eslint-configs

mono repo から CommonJS スタイルを完全に排除して ES Module に統一する(共通ユーティリティ群を esm と cjs 向けにコンパイルしていてビルド時間の無駄が多かった)作業を行う上で、 旧 eslint config 形式である `.eslintrc.js` だけは CommonJS 形式でしか書けないという問題が生じたため、 ESModule 形式でも記述可能な Flat Config の導入に至りました。

Expand Down
4 changes: 2 additions & 2 deletions packages/apps/algo-app/cypress/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import { eslintFlatConfigForCypress } from '@noshiro/eslint-utils';
import { eslintFlatConfigForCypress } from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';

Expand Down
4 changes: 2 additions & 2 deletions packages/apps/algo-app/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import {
eslintFlatConfigForPreact,
genEsLintRestrictedImportsDefFromDevDependencies,
} from '@noshiro/eslint-utils';
} from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';
import packageJson from './package.json' assert { type: 'json' };
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/algo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"preact": "^10.19.6"
},
"devDependencies": {
"@noshiro/eslint-utils": "*",
"@noshiro/eslint-configs": "*",
"@noshiro/global-goober": "*",
"@noshiro/global-preact": "*",
"@noshiro/global-preact-utils": "*",
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/annotation-tool/cypress/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import { eslintFlatConfigForCypress } from '@noshiro/eslint-utils';
import { eslintFlatConfigForCypress } from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';

Expand Down
4 changes: 2 additions & 2 deletions packages/apps/annotation-tool/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import {
eslintFlatConfigForReact,
genEsLintRestrictedImportsDefFromDevDependencies,
} from '@noshiro/eslint-utils';
} from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';
import packageJson from './package.json' assert { type: 'json' };
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/annotation-tool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"uuid": "^9.0.1"
},
"devDependencies": {
"@noshiro/eslint-utils": "*",
"@noshiro/eslint-configs": "*",
"@noshiro/global-emotion-react": "*",
"@noshiro/global-emotion-styled": "*",
"@noshiro/global-react": "*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import { eslintFlatConfigForCypress } from '@noshiro/eslint-utils';
import { eslintFlatConfigForCypress } from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';

Expand Down
4 changes: 2 additions & 2 deletions packages/apps/blueprintjs-playground-styled/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import {
eslintFlatConfigForReact,
genEsLintRestrictedImportsDefFromDevDependencies,
} from '@noshiro/eslint-utils';
} from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';
import packageJson from './package.json' assert { type: 'json' };
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/blueprintjs-playground-styled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@noshiro/eslint-utils": "*",
"@noshiro/eslint-configs": "*",
"@noshiro/global-emotion-react": "*",
"@noshiro/global-emotion-styled": "*",
"@noshiro/global-react": "*",
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/blueprintjs-playground/cypress/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import { eslintFlatConfigForCypress } from '@noshiro/eslint-utils';
import { eslintFlatConfigForCypress } from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';

Expand Down
4 changes: 2 additions & 2 deletions packages/apps/blueprintjs-playground/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import {
eslintFlatConfigForReact,
genEsLintRestrictedImportsDefFromDevDependencies,
} from '@noshiro/eslint-utils';
} from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';
import packageJson from './package.json' assert { type: 'json' };
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/blueprintjs-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@noshiro/eslint-utils": "*",
"@noshiro/eslint-configs": "*",
"@noshiro/global-emotion-react": "*",
"@noshiro/global-emotion-styled": "*",
"@noshiro/global-react": "*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import { eslintFlatConfigForCypress } from '@noshiro/eslint-utils';
import { eslintFlatConfigForCypress } from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';

Expand Down
4 changes: 2 additions & 2 deletions packages/apps/cant-stop-probability-app/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import {
eslintFlatConfigForReact,
genEsLintRestrictedImportsDefFromDevDependencies,
} from '@noshiro/eslint-utils';
} from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';
import packageJson from './package.json' assert { type: 'json' };
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/cant-stop-probability-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@noshiro/eslint-utils": "*",
"@noshiro/eslint-configs": "*",
"@noshiro/global-emotion-react": "*",
"@noshiro/global-emotion-styled": "*",
"@noshiro/global-react": "*",
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/catan-dice-app/cypress/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import { eslintFlatConfigForCypress } from '@noshiro/eslint-utils';
import { eslintFlatConfigForCypress } from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';

Expand Down
4 changes: 2 additions & 2 deletions packages/apps/catan-dice-app/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import {
eslintFlatConfigForReact,
genEsLintRestrictedImportsDefFromDevDependencies,
} from '@noshiro/eslint-utils';
} from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';
import packageJson from './package.json' assert { type: 'json' };
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/catan-dice-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@noshiro/eslint-utils": "*",
"@noshiro/eslint-configs": "*",
"@noshiro/global-emotion-react": "*",
"@noshiro/global-react": "*",
"@noshiro/global-react-utils": "*",
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/color-demo-app/cypress/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import { eslintFlatConfigForCypress } from '@noshiro/eslint-utils';
import { eslintFlatConfigForCypress } from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';

Expand Down
4 changes: 2 additions & 2 deletions packages/apps/color-demo-app/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import {
eslintFlatConfigForReact,
genEsLintRestrictedImportsDefFromDevDependencies,
} from '@noshiro/eslint-utils';
} from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';
import packageJson from './package.json' assert { type: 'json' };
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/color-demo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@noshiro/eslint-utils": "*",
"@noshiro/eslint-configs": "*",
"@noshiro/global-emotion-react": "*",
"@noshiro/global-emotion-styled": "*",
"@noshiro/global-react": "*",
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/event-schedule-app-shared/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import {
eslintFlatConfigCommon,
genEsLintRestrictedImportsDefFromDevDependencies,
} from '@noshiro/eslint-utils';
} from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';
import packageJson from './package.json' assert { type: 'json' };
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/event-schedule-app-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@noshiro/ts-utils-additional": "*"
},
"devDependencies": {
"@noshiro/eslint-utils": "*",
"@noshiro/eslint-configs": "*",
"@noshiro/mono-scripts": "*",
"@noshiro/ts-type-utils": "*"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/event-schedule-app/cypress/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import { eslintFlatConfigForCypress } from '@noshiro/eslint-utils';
import { eslintFlatConfigForCypress } from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';

Expand Down
6 changes: 3 additions & 3 deletions packages/apps/event-schedule-app/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import {
banTypes,
eslintFlatConfigForReact,
genEsLintRestrictedImportsDefFromDevDependencies,
} from '@noshiro/eslint-utils';
} from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';
import packageJson from './package.json' assert { type: 'json' };
Expand All @@ -18,7 +18,7 @@ const defineConfig = async () => {
packageJson.devDependencies,
);

/** @type {import('@noshiro/eslint-utils').RestrictedImportsOption} */
/** @type {import('@noshiro/eslint-configs').RestrictedImportsOption} */
const restrictedImportsAdded = {
paths: [
...restrictedImports[0].paths,
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/event-schedule-app/functions/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import { eslintFlatConfigCommon } from '@noshiro/eslint-utils';
import { eslintFlatConfigCommon } from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';

Expand Down
2 changes: 1 addition & 1 deletion packages/apps/event-schedule-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"url-regex": "^5.0.0"
},
"devDependencies": {
"@noshiro/eslint-utils": "*",
"@noshiro/eslint-configs": "*",
"@noshiro/global-emotion-react": "*",
"@noshiro/global-emotion-styled": "*",
"@noshiro/global-react": "*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import { eslintFlatConfigForCypress } from '@noshiro/eslint-utils';
import { eslintFlatConfigForCypress } from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';

Expand Down
4 changes: 2 additions & 2 deletions packages/apps/housing-loan-calculator-app/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import {
eslintFlatConfigForReact,
genEsLintRestrictedImportsDefFromDevDependencies,
} from '@noshiro/eslint-utils';
} from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';
import packageJson from './package.json' assert { type: 'json' };
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/housing-loan-calculator-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@noshiro/eslint-utils": "*",
"@noshiro/eslint-configs": "*",
"@noshiro/global-emotion-react": "*",
"@noshiro/global-emotion-styled": "*",
"@noshiro/global-react": "*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import {
eslintFlatConfigCommon,
genEsLintRestrictedImportsDefFromDevDependencies,
} from '@noshiro/eslint-utils';
} from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';
import packageJson from './package.json' assert { type: 'json' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@noshiro/ts-utils": "*"
},
"devDependencies": {
"@noshiro/eslint-utils": "*",
"@noshiro/eslint-configs": "*",
"@noshiro/mono-scripts": "*",
"@noshiro/ts-type-utils": "*"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import { eslintFlatConfigForCypress } from '@noshiro/eslint-utils';
import { eslintFlatConfigForCypress } from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import {
eslintFlatConfigForPreact,
genEsLintRestrictedImportsDefFromDevDependencies,
} from '@noshiro/eslint-utils';
} from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';
import packageJson from './package.json' assert { type: 'json' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"preact": "^10.19.6"
},
"devDependencies": {
"@noshiro/eslint-utils": "*",
"@noshiro/eslint-configs": "*",
"@noshiro/global-goober": "*",
"@noshiro/global-preact": "*",
"@noshiro/global-preact-utils": "*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@noshiro/eslint-utils').FlatConfig} FlatConfig */
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */

import { eslintFlatConfigForCypress } from '@noshiro/eslint-utils';
import { eslintFlatConfigForCypress } from '@noshiro/eslint-configs';
import { toThisDir } from '@noshiro/mono-scripts';
import * as nodePath from 'node:path';

Expand Down
Loading

0 comments on commit 98b805b

Please sign in to comment.