1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

FirebaseにTSファイルをDeployする際に起きたエラー メモ

Last updated at Posted at 2021-05-27

ESLint

✖ 41 problems (38 errors, 3 warnings)
  37 errors and 0 warnings potentially fixable with the `--fix` option.

どうやらEslintのエラーに引っかかってたらしく、fixコマンドで修正できるようなので下記コマンドで修正してみます。

eslint index.ts --fix

すると

/Users/(ユーザー名)/charbot-demo/functions/src/index.ts
  0:0  error  Parsing error: Cannot read file '/users/(ユーザー名)/charbot-demo/tsconfig.json'

tsconfig.jsonにアクセス出来ないと突っぱねられました、意味がわかりません。
よくわからないのでeslintのルールを書き換えてみます、.eslintrc.jsのrulusキーの項目を"warn"にします。

rules: {
    quotes: ["warn", "double"],
  },

結果

✖ 34 problems (31 errors, 3 warnings)
  29 errors and 0 warnings potentially fixable with the `--fix` option.

ちょっと消えた....????
やっぱりfixするのが早そうなので原因を探ります。
先ほどのアクセス出来ないと言われたエラー文が'/users/(ユーザー名)/charbot-demo/tsconfig.json'でしたがこんなところにtsconfig.jsonはありません、そこでおかしいとは思うのですが、.eslintrc.jsのparserOptionsオブジェクトの中身を無理やりアクセスできるように変えてみます。

parserOptions: {
    project: ["./function/tsconfig.json", "./function/tsconfig.dev.json"],
    sourceType: "module",
  },

ちなみに階層構造はこんな感じ(必要最低限)。

char-bot 
    |- functions
           |- src
               |- index.ts(エラーなう)
           |- .eslintrc.js
           |- tsconfig.json
       |- tsconfig.json

結果

/Users/(ユーザー名)/charbot-demo/functions/src/index.ts
   8:1   error    This line has a length of 87. Maximum allowed is 80  max-len
   8:79  warning  Unexpected any. Specify a different type             @typescript-eslint/no-explicit-any
  15:1   error    This line has a length of 85. Maximum allowed is 80  max-len
  15:66  warning  Unexpected any. Specify a different type             @typescript-eslint/no-explicit-any
  15:77  warning  Unexpected any. Specify a different type             @typescript-eslint/no-explicit-any

✖ 5 problems (2 errors, 3 warnings)

かなり解消されたみたいですが、まだエラーがあるみたい。
試しにdeployしてみます。

/Users/(ユーザー名)/charbot-demo/functions/.eslintrc.js
  0:0  error  Parsing error: Cannot read file '/users/(ユーザー名)/charbot-demo/functions/functions/tsconfig.json'

/Users/(ユーザー名)/charbot-demo/functions/src/index.ts
  0:0  error  Parsing error: Cannot read file '/users/(ユーザー名)/charbot-demo/functions/functions/tsconfig.json'

✖ 2 problems (2 errors, 0 warnings)

するとtsconfigファイルが読み込めないと表示されるので、先程いじった階層を修正し再度deploy。

/Users/(ユーザー名)/charbot-demo/functions/src/index.ts
   8:1   error    This line has a length of 87. Maximum allowed is 80  max-len
   8:79  warning  Unexpected any. Specify a different type             @typescript-eslint/no-explicit-any
  15:1   error    This line has a length of 85. Maximum allowed is 80  max-len
  15:66  warning  Unexpected any. Specify a different type             @typescript-eslint/no-explicit-any
  15:77  warning  Unexpected any. Specify a different type             @typescript-eslint/no-explicit-any

✖ 5 problems (2 errors, 3 warnings)

かなり減りました(だけどこんなrules設定されてない気がする.....)
でも恐らくmax-len、1行に書きすぎと言われたのでインデントして行を分けます、そのままdeployするとまたエラーが復活したのでもう一度fixした後再度deploy。

Error: Compilation error in firestore.rules:
[E] 5:17 - token recognition error at: ';'

なにこれ....読めばわかりますがどうやらfirestore.rulesの5行目のセミコロンが全角になってますみたいなエラーでした....知るか!!!(firebase initしてから弄ってない)

直してdeploy

✔  Deploy complete!

めでたしめでたし

結論

ESLintに対する知識が全く無いということが身に染みてわかりました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?