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

npm run lint 的 error #74

Closed
xingqiyi opened this issue Feb 2, 2018 · 4 comments · Fixed by #91
Closed

npm run lint 的 error #74

xingqiyi opened this issue Feb 2, 2018 · 4 comments · Fixed by #91
Assignees

Comments

@xingqiyi
Copy link

xingqiyi commented Feb 2, 2018

通过 iceworks 新建的页面

npm run lint 的 error

components/FilterList/SingleItem/SingleItem.jsx
  5:16  error  Component should be written as a pure function  react/prefer-stateless-function

components/BrandDisplay/BrandDisplay.jsx
  42:16  error  Component should be written as a pure function  react/prefer-stateless-function
@wssgcg1213
Copy link
Collaborator

生成的代码格式只是一个示例, 是不是可以考虑放宽 prefer-stateless-function 这一 lint 限制? @yujiangshui

@wssgcg1213 wssgcg1213 self-assigned this Feb 3, 2018
@yujiangshui
Copy link
Contributor

@wssgcg1213
Copy link
Collaborator

wssgcg1213 commented Feb 3, 2018

@chenbin92 麻烦修改一下所有脚手架的 eslint 规则, 放行 react/prefer-stateless-function


@xingqiyi 出现这个的原因是我们的 eslint 规则过于严格, 对于通过iceworks自动生成的页面代码, eslint 认为不符合规范, 我们生成的代码大致格式如下:

import React, { Component } from 'react';

export default class XXXPage extends Component {

  render() {
     return (
       <div>
          <BlockA />
          <BlockB />
       </div>
     );
  }
}

这个代码只是一个类似脚手架的示范, 使用者可以根据自身需求在页面上使用 React 的生命周期方法

所以我们决定放行这一条 eslint 规则, 如果是已经创建的项目, 只需要在 .eslintrc 文件的 rules 字段加上

"react/prefer-stateless-function": 0

就可以了

@wssgcg1213 wssgcg1213 assigned chenbin92 and unassigned wssgcg1213 Feb 3, 2018
@yuanyan
Copy link
Collaborator

yuanyan commented Feb 4, 2018

@xingqiyi 感谢反馈,可以发你的收货地址和联系方式到 ice-admin@alibaba-inc.com ,正式发布后我们会寄送小礼品给你

ClarkXia added a commit that referenced this issue Nov 14, 2022
* feat: update page config after link

* Rename Document.tsx to document.tsx

* chore: add comment

* test: routing

* fix: test utils of puppeteer page

* test: update pageconfig after route

* chore: add origin source

* fix: meta tag

* fix: add s

* feat: reuse the links already loaded

* refactor: hydrate document

* refactor: pass data by app context

* refactor: get assets in document

* refactor: pass app as children

* refactor: use app context

* revert: document

* refactor: pass document by app context

* Rename document.tsx to Document.tsx

* fix: hydrate error

* chore: add comment

* feat: toggle for ssr

* refactor: entry options

* refactor: merge simple functions

* feat: downgrade to csr

* refactor: ssr entry

* fix: file name

* fix: remove deadcode

* Rename generateHtml.ts to generateHTML.ts

* fix: remove deadcode

* fix: remove deadcode

* refactor: remove block scripts

* feat: pass ssr flag to csr

* fix: remove ssg flag

* fix: spelling

* refactor: pass ssr flag to hydrate

* chore: add todo for runtime

* fix: typo

* chore: add todo for load links

* chore: send html for send html

* refactor: remove config for custom rootId

* feat: load page assets

* feat: ssr config

* refactor: disable csr hydrate warning

* chore: add issue link

Co-authored-by: ClarkXia <xiawenwu41@gmail.com>
ClarkXia added a commit that referenced this issue Nov 15, 2022
* feat: update page config after link

* Rename Document.tsx to document.tsx

* chore: add comment

* test: routing

* fix: test utils of puppeteer page

* test: update pageconfig after route

* chore: add origin source

* fix: meta tag

* fix: add s

* feat: reuse the links already loaded

* refactor: hydrate document

* refactor: pass data by app context

* refactor: get assets in document

* refactor: pass app as children

* refactor: use app context

* revert: document

* refactor: pass document by app context

* Rename document.tsx to Document.tsx

* fix: hydrate error

* chore: add comment

* feat: toggle for ssr

* refactor: entry options

* refactor: merge simple functions

* feat: downgrade to csr

* refactor: ssr entry

* fix: file name

* fix: remove deadcode

* Rename generateHtml.ts to generateHTML.ts

* fix: remove deadcode

* fix: remove deadcode

* refactor: remove block scripts

* feat: pass ssr flag to csr

* fix: remove ssg flag

* fix: spelling

* refactor: pass ssr flag to hydrate

* chore: add todo for runtime

* fix: typo

* chore: add todo for load links

* chore: send html for send html

* refactor: remove config for custom rootId

* feat: load page assets

* feat: ssr config

* refactor: disable csr hydrate warning

* chore: add issue link

Co-authored-by: ClarkXia <xiawenwu41@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants