eslint-plugin-smarthr 0.3.4 → 0.3.6
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 +14 -0
- package/libs/common.js +20 -4
- package/package.json +1 -1
- package/rules/a11y-heading-in-sectioning-content/index.js +2 -1
- package/rules/format-import-path/README.md +2 -0
- package/rules/no-import-other-domain/README.md +2 -0
- package/rules/redundant-name/README.md +2 -0
- package/rules/require-barrel-import/README.md +2 -0
- package/test/a11y-heading-in-sectioning-content.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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.3.6](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.3.5...v0.3.6) (2023-08-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* .eslintrc.js などの設定からparserOptions.project が設定されている場合、tsconfig.jsonの読み込み先を変更する ([#68](https://github.com/kufu/eslint-plugin-smarthr/issues/68)) ([3897faf](https://github.com/kufu/eslint-plugin-smarthr/commit/3897fafbf3bf8ccdc42a06700ff832ec97dc7ff1))
|
|
11
|
+
|
|
12
|
+
### [0.3.5](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.3.4...v0.3.5) (2023-07-28)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* a11y-heading-in-sectioning-content で Heading系コンポーネントの拡張をexportしている場合、正しく除外されないバグを修正 ([#67](https://github.com/kufu/eslint-plugin-smarthr/issues/67)) ([a4b8e6d](https://github.com/kufu/eslint-plugin-smarthr/commit/a4b8e6d1081b1e96ad574153805f86d5f7551c5e))
|
|
18
|
+
|
|
5
19
|
### [0.3.4](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.3.3...v0.3.4) (2023-07-18)
|
|
6
20
|
|
|
7
21
|
|
package/libs/common.js
CHANGED
|
@@ -3,13 +3,29 @@ const path = require('path')
|
|
|
3
3
|
const fs = require('fs')
|
|
4
4
|
|
|
5
5
|
const replacePaths = (() => {
|
|
6
|
-
const
|
|
6
|
+
const cwd = process.cwd()
|
|
7
|
+
const eslintrc = (() => {
|
|
8
|
+
let file = `${cwd}/.eslintrc.js`
|
|
9
|
+
if (fs.existsSync(file)) {
|
|
10
|
+
return require(file)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
file = `${cwd}/.eslintrc`
|
|
14
|
+
|
|
15
|
+
if (fs.existsSync(file)) {
|
|
16
|
+
return JSON5.parse(fs.readFileSync(file))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return {}
|
|
20
|
+
})()
|
|
21
|
+
|
|
22
|
+
const tsconfigFile = `${cwd}/${eslintrc.parserOptions?.project || 'tsconfig.json'}`
|
|
7
23
|
|
|
8
|
-
if (!
|
|
9
|
-
throw new Error(
|
|
24
|
+
if (!fs.existsSync(tsconfigFile)) {
|
|
25
|
+
throw new Error(`${tsconfigFile} を設置してください`)
|
|
10
26
|
}
|
|
11
27
|
|
|
12
|
-
const { compilerOptions } = JSON5.parse(
|
|
28
|
+
const { compilerOptions } = JSON5.parse(fs.readFileSync(tsconfigFile))
|
|
13
29
|
|
|
14
30
|
if (!compilerOptions || !compilerOptions.paths) {
|
|
15
31
|
throw new Error('tsconfig.json の compilerOptions.paths に `"@/*": ["any_path/*"]` 形式でフロントエンドのroot dir を指定してください')
|
package/package.json
CHANGED
|
@@ -19,6 +19,7 @@ const bareTagRegex = /^(article|aside|nav|section)$/
|
|
|
19
19
|
const modelessDialogRegex = /ModelessDialog$/
|
|
20
20
|
|
|
21
21
|
const noHeadingTagNames = ['span', 'legend']
|
|
22
|
+
const ignoreHeadingCheckParentType = ['Program', 'ExportNamedDeclaration']
|
|
22
23
|
|
|
23
24
|
const headingMessage = `smarthr-ui/Headingと紐づく内容の範囲(アウトライン)が曖昧になっています。
|
|
24
25
|
- smarthr-uiのArticle, Aside, Nav, SectionのいずれかでHeadingコンポーネントと内容をラップしてHeadingに対応する範囲を明確に指定してください。`
|
|
@@ -48,7 +49,7 @@ const searchBubbleUp = (node) => {
|
|
|
48
49
|
|
|
49
50
|
if (
|
|
50
51
|
// Headingコンポーネントの拡張なので対象外
|
|
51
|
-
node.type === 'VariableDeclarator' && node.parent.parent?.type
|
|
52
|
+
node.type === 'VariableDeclarator' && ignoreHeadingCheckParentType.includes(node.parent.parent?.type) && node.id.name.match(declaratorHeadingRegex) ||
|
|
52
53
|
// ModelessDialogのheaderにHeadingを設定している場合も対象外
|
|
53
54
|
node.type === 'JSXAttribute' && node.name.name === 'header' && node.parent.name.name.match(modelessDialogRegex)
|
|
54
55
|
) {
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
## config
|
|
9
9
|
|
|
10
10
|
- tsconfig.json の compilerOptions.pathsに '@/*', もしくは '~/*' としてroot path を指定する必要があります
|
|
11
|
+
- tsconfig.json はデフォルトではコマンド実行をしたディレクトリから読み込みます
|
|
12
|
+
- tsconfig.json の設置ディレクトリを変更したい場合、 `.eslintrc` などのeslint設定ファイルに `parserOptions.project` を設定してください
|
|
11
13
|
- ドメインを識別するために以下の設定を記述する必要があります
|
|
12
14
|
- globalModuleDir
|
|
13
15
|
- 全体で利用するファイルを収めているディレクトリを相対パスで指定します
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
## config
|
|
8
8
|
|
|
9
9
|
- tsconfig.json の compilerOptions.pathsに '@/*', もしくは '~/*' としてroot path を指定する必要があります
|
|
10
|
+
- tsconfig.json はデフォルトではコマンド実行をしたディレクトリから読み込みます
|
|
11
|
+
- tsconfig.json の設置ディレクトリを変更したい場合、 `.eslintrc` などのeslint設定ファイルに `parserOptions.project` を設定してください
|
|
10
12
|
- ドメインを識別するために以下の設定を記述する必要があります
|
|
11
13
|
- globalModuleDir
|
|
12
14
|
- 全体で利用するファイルを収めているディレクトリを相対パスで指定します
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
## config
|
|
7
7
|
|
|
8
8
|
- tsconfig.json の compilerOptions.pathsに '@/*', もしくは '~/*' としてroot path を指定する必要があります
|
|
9
|
+
- tsconfig.json はデフォルトではコマンド実行をしたディレクトリから読み込みます
|
|
10
|
+
- tsconfig.json の設置ディレクトリを変更したい場合、 `.eslintrc` などのeslint設定ファイルに `parserOptions.project` を設定してください
|
|
9
11
|
- 以下の設定を行えます。全て省略可能です。
|
|
10
12
|
- ignoreKeywords
|
|
11
13
|
- ディレクトリ名から生成されるキーワードに含めたくない文字列を指定します
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# smarthr/require-barrel-import
|
|
2
2
|
|
|
3
3
|
- tsconfig.json の compilerOptions.pathsに '@/*', もしくは '~/*' としてroot path を指定する必要があります
|
|
4
|
+
- tsconfig.json はデフォルトではコマンド実行をしたディレクトリから読み込みます
|
|
5
|
+
- tsconfig.json の設置ディレクトリを変更したい場合、 `.eslintrc` などのeslint設定ファイルに `parserOptions.project` を設定してください
|
|
4
6
|
- importした対象が本来exportされているべきであるbarrel(index.tsなど)が有る場合、import pathの変更を促します
|
|
5
7
|
- 例: Page/parts/Menu/Item の import は Page/parts/Menu から行わせたい
|
|
6
8
|
- ディレクトリ内のindexファイルを捜査し、対象を決定します
|
|
@@ -38,6 +38,7 @@ ruleTester.run('a11y-heading-in-sectioning-content', rule, {
|
|
|
38
38
|
{ code: '<Section><Heading>hoge</Heading></Section>' },
|
|
39
39
|
{ code: '<><Section><Heading>hoge</Heading></Section><Section><Heading>fuga</Heading></Section></>' },
|
|
40
40
|
{ code: 'const HogeHeading = () => <FugaHeading anyArg={abc}>hoge</FugaHeading>' },
|
|
41
|
+
{ code: 'export const HogeHeading = () => <FugaHeading anyArg={abc}>hoge</FugaHeading>' },
|
|
41
42
|
],
|
|
42
43
|
invalid: [
|
|
43
44
|
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|