小编T. *_*uke的帖子

(ESLint/Cypress):解析错误:ESLint 被配置为使用“parserOptions.project”在“<tsconfigRootDir>/component/TestComponent.cy.ts”上运行

我正在使用 Remix (remix.run) 设置一个新项目,并尝试配置 Cypress/ESLint 进行组件测试。我有TestComponent.cy.ts一些样板代码:

describe('TestComponent.cy.ts', () => {
  it('playground', () => {
    // cy.mount()
  })
})
Run Code Online (Sandbox Code Playgroud)

但是,该describe函数会抛出此错误:

    Parsing error: ESLint was configured to run on `<tsconfigRootDir>/component/TestComponent.cy.ts` using `parserOptions.project`: <tsconfigRootDir>/../../../../../../users/tduke/desktop/dev/blog/cypress/tsconfig.json
    However, that TSConfig does not include this file. Either:
    - Change ESLint's list of included files to not include this file
    - Change that TSConfig to include this file
    - Create a new TSConfig that includes this file and include it in your parserOptions.project

Run Code Online (Sandbox Code Playgroud)

我尝试重新配置我的 …

typescript reactjs tsconfig remix typescript-eslint

48
推荐指数
4
解决办法
8万
查看次数

未定义的方法`upload'为nil:NilClass你的意思是?加载

尝试将ActiveStorage用于简单的图像上载表单.它成功创建,但在提交时会抛出错误:

undefined method `upload' for nil:NilClass Did you mean? load
Run Code Online (Sandbox Code Playgroud)

这是它要我看的块:

    @comment = Comment.create! params.require(:comment).permit(:content)
    @comment.image.attach(params[:comment][:image])
    redirect_to comments_path 
  end
Run Code Online (Sandbox Code Playgroud)

这是完整的控制器:

class CommentsController < ApplicationController

  def new
    @comment = Comment.new
  end

  def create
    @comment = Comment.create! params.require(:comment).permit(:content)
    @comment.image.attach(params[:comment][:image])
    redirect_to comments_path 
  end

  def show
    @comment = Comment.find(params[:id])
  end
end
Run Code Online (Sandbox Code Playgroud)

实际应该发生的是它会带你到页面查看上传.这里:

# new.html.erb

   <%= form_with model: @comment, local: true  do |form| %>
   <%= form.text_area :content %><br><br>
    <%= form.file_field :image %><br>
   <%= form.submit %>
  <% end %>

 # show.html.erb
   <%= image_tag @comment.image %>
Run Code Online (Sandbox Code Playgroud)

这是comment.rb …

ruby ruby-on-rails

9
推荐指数
2
解决办法
2541
查看次数