kufu / eslint-plugin-smarthr Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
表題の通り
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
表題の通り
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
こんなかんじで .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
にするとエラーは発生しなくなります。
自分の手元だと同様のバージョンを使っている場合すべてのコンポーネントに対して発生します。
replacePaths
が空値になっており Object.entries
が失敗しているっぽいです。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.