eslint-plugin-smarthr 0.2.10 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/package.json +1 -1
- package/rules/redundant-name/index.js +11 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.2.13](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.2.12...v0.2.13) (2022-12-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* redundant-nameのarrowedNameなどで利用するファイルパスが削られすぎていたため、指定が行いにくい問題を修正する ([4d45281](https://github.com/kufu/eslint-plugin-smarthr/commit/4d45281c383a9996437f3603dd954548f428cd19))
|
|
11
|
+
|
|
12
|
+
### [0.2.12](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.2.11...v0.2.12) (2022-12-07)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* ファイルが複数の.を保つ場合(例 xxx.test.tsx)正常に動作しないバグを修正する ([#42](https://github.com/kufu/eslint-plugin-smarthr/issues/42)) ([23eb5b5](https://github.com/kufu/eslint-plugin-smarthr/commit/23eb5b51039085d3239adca42c65395b81869f9d))
|
|
18
|
+
|
|
19
|
+
### [0.2.11](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.2.10...v0.2.11) (2022-12-07)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* redundant-nameの省略文字列がファイルパスによって正常に生成できないバグを修正 ([49eb1d9](https://github.com/kufu/eslint-plugin-smarthr/commit/49eb1d9ad1e9c153b7cb150190a81e5fae6bedf6))
|
|
25
|
+
|
|
5
26
|
### [0.2.10](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.2.9...v0.2.10) (2022-11-22)
|
|
6
27
|
|
|
7
28
|
### Features
|
package/package.json
CHANGED
|
@@ -86,7 +86,8 @@ const fetchTerminalImportName = (filename) => {
|
|
|
86
86
|
const generateRedundantKeywords = ({ args, key, terminalImportName }) => {
|
|
87
87
|
const option = args.option[key] || {}
|
|
88
88
|
const ignoreKeywords = option.ignoreKeywords || DEFAULT_CONFIG[key].IGNORE_KEYWORDS
|
|
89
|
-
const terminalImportKeyword = terminalImportName ? terminalImportName.toLowerCase() : ''
|
|
89
|
+
const terminalImportKeyword = terminalImportName ? terminalImportName.toLowerCase() : ''
|
|
90
|
+
|
|
90
91
|
return args.keywords.reduce((prev, keyword) => {
|
|
91
92
|
if (keyword === terminalImportKeyword || ignoreKeywords.includes(keyword)) {
|
|
92
93
|
return prev
|
|
@@ -100,7 +101,7 @@ const generateRedundantKeywords = ({ args, key, terminalImportName }) => {
|
|
|
100
101
|
}, [])
|
|
101
102
|
}
|
|
102
103
|
const handleReportBetterName = ({
|
|
103
|
-
key,
|
|
104
|
+
key,
|
|
104
105
|
context,
|
|
105
106
|
option,
|
|
106
107
|
filename,
|
|
@@ -170,13 +171,13 @@ const handleReportBetterName = ({
|
|
|
170
171
|
Object.entries(option.betterNames).forEach(([regex, calc]) => {
|
|
171
172
|
if (calc && filename.match(new RegExp(regex))) {
|
|
172
173
|
switch(calc.operator) {
|
|
173
|
-
case '=':
|
|
174
|
+
case '=':
|
|
174
175
|
candidates = calc.names
|
|
175
176
|
break
|
|
176
|
-
case '-':
|
|
177
|
+
case '-':
|
|
177
178
|
candidates = candidates.filter((c) => !calc.names.includes(c))
|
|
178
179
|
break
|
|
179
|
-
case '+':
|
|
180
|
+
case '+':
|
|
180
181
|
candidates = uniq([...candidates, ...calc.names])
|
|
181
182
|
break
|
|
182
183
|
}
|
|
@@ -412,12 +413,15 @@ module.exports = {
|
|
|
412
413
|
let rules = {}
|
|
413
414
|
|
|
414
415
|
const option = context.options[0]
|
|
415
|
-
|
|
416
|
+
let filename = context.getFilename()
|
|
416
417
|
const keywords = uniq((() => {
|
|
417
418
|
const keywordMatcher = filename.match(new RegExp(`${rootPath}/(.+?)$`))
|
|
418
419
|
|
|
419
420
|
if (keywordMatcher) {
|
|
420
421
|
const keywords = keywordMatcher[1].split('/')
|
|
422
|
+
keywords[keywords.length - 1] = keywords[keywords.length - 1].split('.')[0]
|
|
423
|
+
|
|
424
|
+
filename = `${rootPath}/${keywords.join('/')}`
|
|
421
425
|
|
|
422
426
|
if (keywords[keywords.length - 1] === 'index') {
|
|
423
427
|
keywords.pop()
|
|
@@ -435,7 +439,7 @@ module.exports = {
|
|
|
435
439
|
return []
|
|
436
440
|
})())
|
|
437
441
|
|
|
438
|
-
const args = {
|
|
442
|
+
const args = {
|
|
439
443
|
context,
|
|
440
444
|
option,
|
|
441
445
|
filename,
|