Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-smarthr

Package Overview
Dependencies
Maintainers
0
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-smarthr - npm Package Compare versions

Comparing version 0.5.20 to 1.0.0

11

CHANGELOG.md

@@ -5,2 +5,13 @@ # Changelog

## [1.0.0](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.5.20...v1.0.0) (2024-12-12)
### ⚠ BREAKING CHANGES
ESLint v9 及び FlatConfig への対応をしました。
これにともない、ESLint v8 以下及び LegacyConfig では利用できなくなりました。
* ESLint v9 ([#154](https://github.com/kufu/eslint-plugin-smarthr/issues/154)) ([a0b79fd](https://github.com/kufu/eslint-plugin-smarthr/commit/a0b79fd39fcab103008f9a257fb29d7d0e9c662b))
### [0.5.20](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.5.18...v0.5.20) (2024-11-25)

@@ -7,0 +18,0 @@

14

index.js

@@ -8,8 +8,12 @@ 'use strict';

/**
* @type {import('eslint').Linter.Config}
*/
module.exports = {
configs: {
name: 'eslint-plugin-smarthr',
rules,
plugins: {
recommended: generateRecommendedConfig(rules),
},
rules,
};
}
}

@@ -29,3 +33,3 @@ function generateRulesMap() {

let config = {
plugins: ['smarthr'],
name: 'eslint-plugin-smarthr/recommended',
rules: {},

@@ -32,0 +36,0 @@ };

{
"name": "eslint-plugin-smarthr",
"version": "0.5.20",
"version": "1.0.0",
"author": "SmartHR",

@@ -8,2 +8,5 @@ "license": "MIT",

"main": "index.js",
"engines": {
"node": ">=20.9.0"
},
"scripts": {

@@ -26,12 +29,12 @@ "test": "jest",

"dependencies": {
"json5": "^2.2.0"
"json5": "^2.2.3"
},
"devDependencies": {
"eslint": "^8.8.0",
"jest": "^27.4.7",
"standard-version": "^9.3.2",
"typescript-eslint": "^7.5.0"
"eslint": "^9.15.0",
"jest": "^29.7.0",
"standard-version": "^9.5.0",
"typescript-eslint": "^8.14.0"
},
"peerDependencies": {
"eslint": "^7 || ^8"
"eslint": "^9"
},

@@ -38,0 +41,0 @@ "keywords": [

@@ -144,3 +144,3 @@ const { rootPath } = require('../../libs/common')

create(context) {
const filenames = context.getFilename().replace(rootPathSlashed, '').replace(extRegex, '').split('/')
const filenames = context.filename.replace(rootPathSlashed, '').replace(extRegex, '').split('/')
const isInnerForm = filenames.some(includeWrapper)

@@ -147,0 +147,0 @@ const notified = []

@@ -128,3 +128,3 @@ const path = require('path')

node,
context.getSourceCode().getText(node).replace(new RegExp(`from '${importPath}'$`), `from '${fixedImportPath}'`)
context.sourceCode.getText(node).replace(new RegExp(`from '${importPath}'$`), `from '${fixedImportPath}'`)
),

@@ -134,5 +134,5 @@ })

},
}
};
},
}
module.exports.schema = SCHEMA

@@ -38,4 +38,3 @@ const SCHEMA = [

const option = context.options[0]
const sourceCode = context.getSourceCode()
const attributeCode = sourceCode.getText(node)
const attributeCode = context.sourceCode.getText(node)

@@ -53,3 +52,3 @@ context.report({

if (a !== node) {
p = [...p, sourceCode.getText(a)]
p = [...p, context.sourceCode.getText(a)]
}

@@ -68,5 +67,5 @@

},
}
};
},
}
module.exports.schema = SCHEMA

@@ -22,4 +22,3 @@ const SCHEMA = [{

const options = context.options[0]
const filename = context.getFilename()
const targetPaths = Object.keys(options).filter((regex) => !!filename.match(new RegExp(regex)))
const targetPaths = Object.keys(options).filter((regex) => !!context.filename.match(new RegExp(regex)))

@@ -36,3 +35,3 @@

matcher = filename.match(new RegExp(path))
matcher = context.filename.match(new RegExp(path))

@@ -39,0 +38,0 @@ if (matcher) {

@@ -45,5 +45,4 @@ const path = require('path')

const options = context.options[0]
const filename = context.getFilename()
const parentDir = (() => {
const dir = filename.match(/^(.+?)\..+?$/)[1].split('/')
const dir = context.filename.match(/^(.+?)\..+?$/)[1].split('/')
dir.pop()

@@ -54,3 +53,3 @@

const targetPathRegexs = Object.keys(options)
const targetProhibits = targetPathRegexs.filter((regex) => !!filename.match(new RegExp(regex)))
const targetProhibits = targetPathRegexs.filter((regex) => !!context.filename.match(new RegExp(regex)))

@@ -57,0 +56,0 @@ if (targetProhibits.length === 0) {

@@ -96,13 +96,12 @@ const path = require('path')

const option = context.options[0] || {}
const filename = context.getFilename()
if (option.ignores && option.ignores.some((i) => !!filename.match(new RegExp(i)))) {
if (option.ignores && option.ignores.some((i) => !!context.filename.match(new RegExp(i)))) {
return {}
}
let d = filename.split('/')
let d = context.filename.split('/')
d.pop()
const dir = d.join('/')
const targetPathRegexs = Object.keys(option?.allowedImports || {})
const targetAllowedImports = targetPathRegexs.filter((regex) => !!filename.match(new RegExp(regex)))
const targetAllowedImports = targetPathRegexs.filter((regex) => !!context.filename.match(new RegExp(regex)))

@@ -109,0 +108,0 @@ return {

@@ -53,5 +53,4 @@ const SCHEMA = [

const options = context.options[0]
const filename = context.getFilename()
const targetPathRegexs = Object.keys(options)
const targetRequires = targetPathRegexs.filter((regex) => !!filename.match(new RegExp(regex)))
const targetRequires = targetPathRegexs.filter((regex) => !!context.filename.match(new RegExp(regex)))

@@ -109,3 +108,3 @@ if (targetRequires.length === 0) {

} else if (localOption.use) {
const code = context.getSourceCode().getText(hit)
const code = context.sourceCode.getText(hit)
let reported = false

@@ -126,3 +125,3 @@

},
}
};
},

@@ -129,0 +128,0 @@ }

@@ -33,5 +33,4 @@ const SCHEMA = [{

const options = context.options[0]
const filename = context.getFilename()
const targetPathRegexs = Object.keys(options)
const targetRequires = targetPathRegexs.filter((regex) => !!filename.match(new RegExp(regex)))
const targetRequires = targetPathRegexs.filter((regex) => !!context.filename.match(new RegExp(regex)))

@@ -38,0 +37,0 @@ if (targetRequires.length === 0) {

@@ -45,5 +45,4 @@ const path = require('path')

const options = context.options[0]
const filename = context.getFilename()
const targetPathRegexs = Object.keys(options)
const targetRequires = targetPathRegexs.filter((regex) => !!filename.match(new RegExp(regex)))
const targetRequires = targetPathRegexs.filter((regex) => !!context.filename.match(new RegExp(regex)))

@@ -58,3 +57,3 @@ if (targetRequires.length === 0) {

const parentDir = (() => {
const dir = filename.match(/^(.+?)\..+?$/)[1].split('/')
const dir = context.filename.match(/^(.+?)\..+?$/)[1].split('/')
dir.pop()

@@ -71,3 +70,3 @@

if (targetRegex && !filename.match(new RegExp(targetRegex))) {
if (targetRegex && !context.filename.match(new RegExp(targetRegex))) {
return

@@ -74,0 +73,0 @@ }

@@ -5,12 +5,10 @@ const rule = require('../rules/a11y-anchor-has-href-attribute')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const generateErrorText = (name) => `${name} に href 属性を正しく設定してください

@@ -17,0 +15,0 @@ - onClickなどでページ遷移する場合でもhref属性に遷移先のURIを設定してください

@@ -5,12 +5,10 @@ const rule = require('../rules/a11y-clickable-element-has-text')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const defaultErrorMessage = `a, buttonなどのクリッカブルな要素内にはテキストを設定してください

@@ -153,3 +151,2 @@ - 要素内にアイコン、画像のみを設置する場合はaltなどの代替テキスト用属性を指定してください

{ code: 'const Fuga = styled(HogeAnchor)``', errors: [ { message: `Fugaを正規表現 "/Anchor$/" がmatchする名称に変更してください。` } ] },
{ code: 'const Fuga = styled(HogeAnchor)``', errors: [ { message: `Fugaを正規表現 "/Anchor$/" がmatchする名称に変更してください。` } ] },
{ code: 'const Fuga = styled(SmartHRLogo)``', errors: [ { message: `Fugaを正規表現 "/SmartHRLogo$/" がmatchする名称に変更してください。` } ] },

@@ -156,0 +153,0 @@ { code: 'const Piyo = styled.a(() => ``)', errors: [ { message: `Piyoを正規表現 "/(Anchor|Link)$/" がmatchする名称に変更してください。` } ] },

@@ -5,11 +5,10 @@ const rule = require('../rules/a11y-delegate-element-has-role-presentation');

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
});
})

@@ -16,0 +15,0 @@ const defaultInteractiveRegex = '/((i|I)nput$|(t|T)extarea$|(s|S)elect$|InputFile$|RadioButtonPanel$|Check(b|B)ox$|Combo(b|B)ox$|DatePicker$|TimePicker$|DropZone$|Switch$|SegmentedControl$|RightFixedNote$|FieldSet$|Fieldset$|FormControl$|FormGroup$|(b|B)utton$|Anchor$|Link$|TabItem$|^a$|(f|F)orm$|ActionDialogWithTrigger$|RemoteDialogTrigger$|RemoteTrigger(.+)Dialog$|FormDialog$|Pagination$|SideNav$|AccordionPanel$|FilterDropdown$)/'

@@ -5,12 +5,10 @@ const rule = require('../rules/a11y-form-control-in-form')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const generateErrorText = (elementName) => `${elementName}をform要素で囲むようにマークアップしてください。

@@ -17,0 +15,0 @@ - form要素で囲むことでスクリーンリーダーに入力フォームであることが正しく伝わる、入力要素にfocusした状態でEnterを押せばsubmitできる、inputのpattern属性を利用できるなどのメリットがあります

@@ -5,11 +5,10 @@ const rule = require('../rules/a11y-heading-in-sectioning-content');

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
});
})

@@ -16,0 +15,0 @@ const lowerMessage = `smarthr-ui/Headingと紐づく内容の範囲(アウトライン)が曖昧になっています。

@@ -5,12 +5,10 @@ const rule = require('../rules/a11y-image-has-alt-attribute')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const messageNotExistAlt = `画像にはalt属性を指定してください。

@@ -17,0 +15,0 @@ - コンポーネントが画像ではない場合、img or image を末尾に持たない名称に変更してください。

@@ -5,11 +5,10 @@ const rule = require('../rules/a11y-input-has-name-attribute');

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
});
})

@@ -16,0 +15,0 @@ const MESSAGE_SUFFIX = `

@@ -5,12 +5,10 @@ const rule = require('../rules/a11y-input-in-form-control')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const noLabeledInput = (name) => `${name} を、smarthr-ui/FormControl もしくはそれを拡張したコンポーネントが囲むようマークアップを変更してください。

@@ -17,0 +15,0 @@ - FormControlで入力要素を囲むことでラベルと入力要素が適切に紐づき、操作性が高まります

@@ -5,12 +5,10 @@ const rule = require('../rules/a11y-numbered-text-within-ol')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
ruleTester.run('a11y-numbered-text-within-ol', rule, {

@@ -17,0 +15,0 @@ valid: [

@@ -5,12 +5,10 @@ const rule = require('../rules/a11y-prohibit-input-placeholder')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
ruleTester.run('a11y-prohibit-input-placeholder', rule, {

@@ -17,0 +15,0 @@ valid: [

@@ -5,12 +5,10 @@ const rule = require('../rules/a11y-prohibit-input-maxlength-attribute')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const expectedErrorMessage = (elName) => `${elName}にmaxLength属性を設定しないでください。

@@ -17,0 +15,0 @@ - maxLength属性がついた要素に、テキストをペーストすると、maxLength属性の値を超えた範囲が意図せず切り捨てられてしまう場合があります

@@ -5,12 +5,10 @@ const rule = require('../rules/a11y-prohibit-useless-sectioning-fragment')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const error = (tag) => `無意味なSectioningFragmentが記述されています。子要素である${tag}で問題なくセクションは設定されているため、このSectioningFragmentは削除してください`

@@ -17,0 +15,0 @@

@@ -10,9 +10,8 @@ const rule = require('../rules/a11y-replace-unreadable-symbol')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 2018,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},

@@ -19,0 +18,0 @@ })

@@ -5,12 +5,10 @@ const rule = require('../rules/a11y-trigger-has-button')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
ruleTester.run('a11y-trigger-has-button', rule, {

@@ -17,0 +15,0 @@ valid: [

@@ -5,12 +5,10 @@ const rule = require('../rules/best-practice-for-button-element')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const ERRORMESSAGE_REQUIRED_TYPE_ATTR = `button要素を利用する場合、type属性に "button" もしくは "submit" を指定してください

@@ -17,0 +15,0 @@ - button要素のtype属性のデフォルトは "submit" のため、button要素がformでラップされていると意図しないsubmitを引き起こす可能性があります

@@ -5,12 +5,10 @@ const rule = require('../rules/best-practice-for-data-test-attribute')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const generateErrorMessage = (attr) => `テストのために要素を指定するために、${attr} 属性を利用するのではなく、他の方法で要素を指定することを検討してください。

@@ -17,0 +15,0 @@ - 方法1: click_link, click_button等を利用したりすることで、利用しているテスト環境に準じた方法で要素を指定することを検討してください。

@@ -5,12 +5,10 @@ const rule = require('../rules/best-practice-for-date')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const errorNewDate = `'new Date(arg)' のように引数を一つだけ指定したDate instanceの生成は実行環境によって結果が異なるため、以下のいずれかの方法に変更してください

@@ -17,0 +15,0 @@ - 'new Date(2022, 12 - 1, 31)' のように数値を個別に指定する

@@ -5,12 +5,10 @@ const rule = require('../rules/best-practice-for-layouts')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const errorMessage = (type, name) => `${name}には子要素が一つしか無いため、${type}でマークアップする意味がありません。

@@ -17,0 +15,0 @@ - styleを確認し、div・spanなど、別要素でマークアップし直すか、${name}を削除してください

@@ -5,12 +5,10 @@ const rule = require('../rules/best-practice-for-remote-trigger-dialog')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
ruleTester.run('best-practice-for-remote-trigger-dialog', rule, {

@@ -17,0 +15,0 @@ valid: [

@@ -5,12 +5,10 @@ const rule = require('../rules/design-system-guideline-prohibit-double-icons')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const generateErrorText = (name) => `${name} には prefix と suffix は同時に設定できません。

@@ -17,0 +15,0 @@ - prefix または suffix のみを設定してください。

@@ -5,12 +5,10 @@ const rule = require('../rules/format-translate-component')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const options = [

@@ -17,0 +15,0 @@ {

@@ -5,5 +5,8 @@ const rule = require('../rules/prohibit-file-name')

const ruleTester = new RuleTester({
parserOptions: {
sourceType: 'module',
ecmaVersion: 12
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},

@@ -10,0 +13,0 @@ })

@@ -5,5 +5,8 @@ const rule = require('../rules/prohibit-import')

const ruleTester = new RuleTester({
parserOptions: {
sourceType: 'module',
ecmaVersion: 12
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},

@@ -10,0 +13,0 @@ })

@@ -5,5 +5,8 @@ const rule = require('../rules/prohibit-path-within-template-literal')

const ruleTester = new RuleTester({
parserOptions: {
sourceType: 'module',
ecmaVersion: 12
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},

@@ -10,0 +13,0 @@ })

@@ -5,12 +5,10 @@ const rule = require('../rules/require-declaration')

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 12,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: 'module',
},
})
const options = [

@@ -17,0 +15,0 @@ {

@@ -5,5 +5,8 @@ const rule = require('../rules/require-export')

const ruleTester = new RuleTester({
parserOptions: {
sourceType: 'module',
ecmaVersion: 12
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},

@@ -10,0 +13,0 @@ })

@@ -5,5 +5,8 @@ const rule = require('../rules/require-import')

const ruleTester = new RuleTester({
parserOptions: {
sourceType: 'module',
ecmaVersion: 12
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},

@@ -10,0 +13,0 @@ })

@@ -5,5 +5,7 @@ const rule = require('../rules/trim-props')

const ruleTester = new RuleTester({
parserOptions: {
ecmaFeatures: {
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},

@@ -10,0 +12,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc