Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
eslint-plugin-smarthr
Advanced tools
{
rules: {
'smarthr/a11y-icon-button-has-name': 'error', // 'warn', 'off'
},
}
<XxxButton>
<YyyIcon />
</XxxButton>
<XxxButton>
<YyyIcon />
Hoge
</XxxButton>
<XxxButton>
<YyyIcon />
<AnyComponent />
</XxxButton>
<XxxButton>
<YyyIcon visuallyHiddenText="hoge" />
</XxxButton>
--fix
オプション付きで実行すると自動的にパスを置き換えます/ constants
/ modules // 全体共通ディレクトリ
/ crews
/ modules // 共通ディレクトリ
/ views
/ parts
/ index
/ adapters
/ index.ts
/ hoge.ts
/ slices
/ index.ts
/ views
/ index.ts
/ parts
/ Abc.ts
/ show
/ views
/ parts
const DOMAIN_RULE_ARGS = {
globalModuleDir: [ './constants', './modules' ],
domainModuleDir: [ 'modules' ],
domainConstituteDir: [ 'adapters', 'slices', 'views', 'parts' ],
}
{
rules: {
'smarthr/format-import-path': [
'error', // 'warn', 'off'
{
...DOMAIN_RULE_ARGS,
format: {
// 'relative', 'auto', 'none'
// all: 'absolute',
outside: 'auto',
globalModule: 'absolute',
module: 'relative',
domain: 'relative',
lower: 'relative',
},
},
],
},
}
// crews/index/views/index.js
import slice from '@/crews/index/slice'
import hoge from '@/crews/index/adapter/hoge'
import Abc from '@/crews/index/views/parts/Abc'
import modulePart from '@/crews/modules/views/part'
import showPart from '../../show/views/parts'
import globalModulePart from '../../../module/views/part'
// crews/index/views/index.js
import slice from '../slice'
import hoge from '../adapter/hoge'
import Abc from './parts/Abc'
import modulePart from '../../modules/views/parts'
import showPart from '@/crews/show/views/parts'
import globalModulePart from '@/modules/views/parts'
--fix
オプション付きで実行する際、 fix option を true にすると自動修正します{
rules: {
'smarthr/jsx-start-with-spread-attributes': [
'error', // 'warn', 'off'
{
fix: false, // true
},
]
},
}
<AnyComponent hoge="hoge" {...props} />
<AnyComponent {...props} hoge="hoge" />
/ constants
/ modules // 全体共通ディレクトリ
/ crews
/ modules // 共通ディレクトリ
/ views
/ parts
/ index
/ adapters
/ index.ts
/ hoge.ts
/ slices
/ index.ts
/ views
/ index.ts
/ parts
/ Abc.ts
/ show
/ views
/ parts
const DOMAIN_RULE_ARGS = {
globalModuleDir: [ './constants', './modules' ],
domainModuleDir: [ 'modules' ],
domainConstituteDir: [ 'adapters', 'slices', 'views', 'parts' ],
}
{
rules: {
'smarthr/no-import-other-domain': [
'error', // 'warn', 'off'
{
...DOMAIN_RULE_ARGS,
// analyticsMode: 'all', // 'same-domain', 'another-domain'
}
]
},
}
// crews/index/views/index.js
import showPart1 from '@/crews/show/views/parts'
import showPart2 from '../../show/views/parts'
// crews/index/views/index.js
import slice from '../slice'
import hoge from '../adapter/hoge'
import Abc from './parts/Abc'
import modulePart from '../../modules/views/parts'
import globalModulePart from '@/modules/views/parts'
{
rules: {
'smarthr/prohibit-import': [
'error', // 'warn', 'off'
{
'^.+$': {
'smarthr-ui': {
imported: ['SecondaryButtonAnchor'],
reportMessage: `{{module}}/{{export}} はXxxxxxなので利用せず yyyy/zzzz を利用してください`
},
}
'\/pages\/views\/': {
'query-string': {
imported: true,
},
},
}
]
},
}
// src/pages/views/Page.tsx
import queryString from 'query-string'
import { SecondaryButtonAnchor } from 'smarthr-ui'
// src/pages/views/Page.tsx
import { PrimaryButton, SecondaryButton } from 'smarthr-ui'
{
rules: {
'smarthr/require-import': [
'error',
{
'Buttons\/.+\.tsx': {
'smarthr-ui': {
imported: ['SecondaryButton'],
reportMessage: 'Buttons以下のコンポーネントでは {{module}}/{{export}} を拡張するようにしてください',
},
},
'Page.tsx$': {
'./client/src/hooks/useTitle': {
imported: true,
reportMessage: '{{module}} を利用してください(ページタイトルを設定するため必要です)',
},
},
},
]
},
}
// client/src/Buttons/SecondaryButton.tsx
import { SecondaryButtonAnchor } from 'smarthr-ui'
// client/src/Page.tsx
import { SecondaryButton } from 'smarthr-ui'
// client/src/Buttons/SecondaryButton.tsx
import { SecondaryButton } from 'smarthr-ui'
// client/src/Page.tsx
import useTitle from '.hooks/useTitle'
{
rules: {
'smarthr/require-barrel-import': 'error',
},
}
// client/src/views/Page/parts/Menu/index.ts
export { Menu } from './Menu'
export { Item } from './Item'
// client/src/App.tsx
import { Item } from './Page/parts/Menu/Item'
// client/src/views/Page/parts/Menu/index.ts
export { Menu } from './Menu'
export { Item } from './Item'
// client/src/App.tsx
import { Item } from './Page/parts/Menu'
@/crews/index/views/page.tsx
の場合
['crews', 'crew', 'index', 'page']
@/crews/index/views/parts/Abc.tsx
の場合
['crews', 'crew', 'index', 'Abc']
@/crews/index/repositories/index.ts
の場合
['crews', 'crew', 'index', 'repositories', 'repository']
const ignorekeywords = ['views', 'parts']
const betterNames = {
'\/repositories\/': {
operator: '-',
names: ['repository', 'Repository'],
},
'\/entities\/': {
operator: '+',
names: ['entity'],
},
'\/slices\/': {
operator: '=',
names: ['index'],
},
}
{
rules: {
'smarthr/redundant-name': [
'error', // 'warn', 'off'
{
type: { ignorekeywords, suffix: ['Props', 'Type'] },
file: { ignorekeywords, betternames },
// property: { ignorekeywords },
// function: { ignorekeywords },
// variable: { ignorekeywords },
// class: { ignorekeywords },
}
]
},
}
// @/crews/index/views/page.tsx
type CrewIndexPage = { hoge: string }
type CrewsView = { hoge: string }
// @/crews/show/repositories/index.tsx
type CrewIndexRepository = { hoge: () => any }
// @/crews/index/views/page.tsx
type ItemProps = { hoge: string }
// @/crews/show/repositories/index.tsx
type IndexProps = { hoge: () => any }
type ResponseType = { hoge: () => any }
``
FAQs
A sharable ESLint plugin for SmartHR
The npm package eslint-plugin-smarthr receives a total of 6,180 weekly downloads. As such, eslint-plugin-smarthr popularity was classified as popular.
We found that eslint-plugin-smarthr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.