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

eslint-plugin-smarthr

Package Overview
Dependencies
Maintainers
22
Versions
86
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.3.8 to 0.3.9

7

CHANGELOG.md

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

### [0.3.9](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.3.8...v0.3.9) (2023-09-04)
### Features
* `new Date("YYYY/MM/DD")` のように日付文字列を直接設定している場合 `new Date(YYYY, MM - 1, DD)` に置き換えるfixerを追加 ([#76](https://github.com/kufu/eslint-plugin-smarthr/issues/76)) ([16a689a](https://github.com/kufu/eslint-plugin-smarthr/commit/16a689a6fe9ef240baaf66bcac08992328a64c4e))
### [0.3.8](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.3.7...v0.3.8) (2023-09-01)

@@ -7,0 +14,0 @@

2

package.json
{
"name": "eslint-plugin-smarthr",
"version": "0.3.8",
"version": "0.3.9",
"author": "SmartHR",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -8,6 +8,27 @@ const MESSAGE_NEW_DATE = `'new Date(arg)' のように引数を一つだけ指定したDate instanceの生成は実行環境によって結果が異なるため、以下のいずれかの方法に変更してください

const SEPARATOR = '(\/|-)'
const DATE_REGEX = new RegExp(`^([0-9]{4})${SEPARATOR}([0-9]{1,2})${SEPARATOR}([0-9]{1,2})`)
const fixAction = (fixer, node, replacedSuffix = '') => {
const arg = node.arguments[0]
if (arg.type == 'Literal') {
const parsedArgs = arg.value.match(DATE_REGEX)
if (parsedArgs) {
return fixer.replaceText(
node,
`new Date(${parsedArgs[1] * 1}, ${parsedArgs[3] * 1} - 1, ${parsedArgs[5] * 1})${replacedSuffix}`
)
}
}
}
const SCHEMA = []
module.exports = {
meta: {
type: 'problem',
schema: [],
fixable: 'code',
schema: SCHEMA,
},

@@ -24,2 +45,3 @@ create(context) {

message: MESSAGE_NEW_DATE,
fix: (fixer) => fixAction(fixer, node),
});

@@ -36,2 +58,3 @@ }

message: MESSAGE_PARSE,
fix: (fixer) => fixAction(fixer, node, '.getTime()'),
});

@@ -43,2 +66,2 @@ }

}
module.exports.schema = []
module.exports.schema = SCHEMA
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