Giter VIP home page Giter VIP logo

eslint-plugin-smarthr's People

Contributors

atsushim avatar f440 avatar kinoppyd avatar nabeliwo avatar negiandleek avatar takahirohimi avatar tokky0425 avatar yamish123 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eslint-plugin-smarthr's Issues

a11y-clickable-element-has-text と smarthr-ui の SmartHRLogo の組み合わせでエラー

表題の通り
smarthr-ui の <SmartHRLogo /> をリンクとして扱うとエラーになる

a, button要素にはテキストを設定してください。要素内にアイコン、画像のみを設置する場合はSmartHR UIのvisuallyHiddenText、通常のHTML要素にはaltなどの代替テキスト用属性を指定してくださいeslint(smarthr/a11y-clickable-element-has-text)
<a href="hoge">
  <SmartHRLogo />
</a>

📝
SmartHRLogo は引数で title を受け取り、aria-label に設定している
https://github.com/kufu/smarthr-ui/blob/master/src/components/SmartHRLogo/SmartHRLogo.tsx#L60

a11y-image-has-alt-attribute と smarthr-ui の BlankImage の組み合わせでエラー

表題の通り
smarthr-ui の <BlankImage /> に対して以下のエラーが出る

<BlankImage />
画像にはalt属性を指定してください。SVG component の場合、altを属性として受け取れるようにした上で `<svg role="img" aria-label={alt}>` のように指定してください。画像ではない場合、img or image を末尾に持たない名称に変更してください。eslint(smarthr/a11y-image-has-alt-attribute)

📝
BlankImage は引数で title を受け取り、svg の <title>aria-label に設定している
https://github.com/kufu/smarthr-ui/blob/master/src/components/Image/BlankImage.tsx#L27

`require-barrel-import` を `warn` 以上に設定するとエラーになる

Environment

  • macOS Monteray 12.6.2
  • node 18.16.0
  • eslint 8.41.0
  • eslint-config-smarthr 6.8.5
  • eslint-plugin-smarthr 0.3.1

How to Reproduction

こんなかんじで .eslintrc を設定します

{
  "extends": "smarthr",
  "rules": {
    "smarthr/require-barrel-import": "warn"
  }
}

Lintをかけると以下エラーが発生します

$ ./node_modules/.bin/eslint './client/**/*.ts{,x}'

Oops! Something went wrong! :(

ESLint: 8.41.0

TypeError: Cannot convert undefined or null to object
Occurred while linting /path/to/project/client/src/path/to/Component.tsx:1
Rule: "smarthr/require-barrel-import"
    at Function.entries (<anonymous>)
    at calculateAbsoluteImportPath (/path/to/project/node_modules/eslint-plugin-smarthr/rules/require-barrel-import/index.js:9:17)
    at ImportDeclaration (/path/to/project/node_modules/eslint-plugin-smarthr/rules/require-barrel-import/index.js:143:23)
    at ruleErrorHandler (/path/to/project/node_modules/eslint/lib/linter/linter.js:1050:28)
    at /path/to/project/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/path/to/project/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/path/to/project/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/path/to/project/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (/path/to/project/node_modules/eslint/lib/linter/node-event-generator.js:340:14)

当該ルールを off にするとエラーは発生しなくなります。
自分の手元だと同様のバージョンを使っている場合すべてのコンポーネントに対して発生します。

Maybe Helps

replacePaths が空値になっており Object.entries が失敗しているっぽいです。

return Object.entries(replacePaths).reduce((prev, [key, values]) => {

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.