Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] @cybozu/eslint-config が入っていないとdts-genが動かない #39

Open
the-red opened this issue Jun 21, 2023 · 3 comments
Assignees
Labels
bug Something isn't working pkg: dts-gen @kintone/dts-gen

Comments

@the-red
Copy link

the-red commented Jun 21, 2023

概要

Next.jsからkintone REST APIを叩く機能を作ろうとして、
dts-genを入れて型定義ファイルを作ろうとしたところ、エラーが出ました。

@cybozu/eslint-config が無いと叱られたので、
試しにインストールしてみたところエラーは消えましたが、
ESLintとdts-genは全く関係ないので、このようなエラーは出ないようにしてほしいです。

対象パッケージ

@kintone/dts-gen

対象バージョン

v7.0.1

再現手順

ESLintがインストールされていない場合は発生しないように見えます。
ESLintがすでに入っていて、@cybozu/eslint-configは入ってない場合に発生しましたが、
それも再現率100%ではないので、そこまで詳しく見れていません。
取り急ぎ報告だけしておきます。

パッケージマネージャーはyarnを使っています。

期待する挙動

@cybozu/eslint-config をインストールしなくても動く

実際の挙動

実行するとこうなりました。

$ kintone-dts-gen --base-url xxx --api-token xxx --app-id xxx 
Error: Failed to load config "@cybozu/eslint-config/presets/typescript" to extend from.
Referenced from: BaseConfig
    at configInvalidError (/path/to/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2627:9)
    at ConfigArrayFactory._loadExtendedShareableConfig (/path/to/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3258:23)
    at ConfigArrayFactory._loadExtends (/path/to/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3135:25)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/path/to/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3074:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData (/path/to/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:20)
    at _normalizeObjectConfigData.next (<anonymous>)
    at ConfigArrayFactory.create (/path/to/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2814:16)
    at createBaseConfigArray (/path/to/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3564:48)
    at new CascadingConfigArrayFactory (/path/to/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3704:30) {
  messageTemplate: 'extend-config-missing',
  messageData: {
    configName: '@cybozu/eslint-config/presets/typescript',
    importerName: ''
  }
}

環境

  System:
    OS: macOS 13.4
    CPU: (10) arm64 Apple M1 Pro
    Memory: 46.31 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.20.0 - ~/.anyenv/envs/nodenv/versions/16.20.0/bin/node
    Yarn: 1.22.19 - ~/.anyenv/envs/nodenv/versions/16.20.0/bin/yarn
    npm: 8.19.4 - ~/.anyenv/envs/nodenv/versions/16.20.0/bin/npm
  npmPackages:
    @kintone/dts-gen: ^7.0.1 => 7.0.1 
    @kintone/rest-api-client: ^4.0.1 => 4.0.1 
    typescript: ^5.0.4 => 5.0.4 
@the-red the-red added the bug Something isn't working label Jun 21, 2023
@tasshi-me tasshi-me added the pkg: dts-gen @kintone/dts-gen label Jun 22, 2023
@tasshi-me tasshi-me self-assigned this Jun 22, 2023
@tasshi-me
Copy link
Member

@the-red
フィードバックいただきありがとうございます!

dts-genでは生成した型定義ファイルに内部でESLint/Prettierを実行しております。
#22 の要望を元に @kintone/dts-gen@6.1.0 で追加)

こちら手元で再現できなかったので、よろしければyarn listの実行結果もいただけますでしょうか?
dts-genはdependenciesに@cybozu/eslint-configを指定しているので、dts-genのインストール時に自動的に@cybozu/eslint-configもインストールされるはずなのですが、何かしらの原因で上手く依存関係が解決されていないのかもしれません。

@the-red
Copy link
Author

the-red commented Jun 22, 2023

@mshrtsr
なるほど、ESLint/Prettierでフォーマットしているわけですか。
それならこの挙動も起こり得ますね。
再現できるようなパブリックリポジトリ準備しますので、少しお待ち下さい。

あと、せっかくなら手元のprettierの設定ファイルに準拠したフォーマットして欲しいと思ったので、
そっちは機能要望として別Issue上げさせてもらいますw

@tasshi-me
Copy link
Member

FYI: 今回のケースと別で、TypeScriptも依存として正しく設定されていないことが分かったためIssue登録しました。
kintone/js-sdk#2152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg: dts-gen @kintone/dts-gen
Projects
None yet
Development

No branches or pull requests

2 participants