eslint-config-matsuri 0.0.0 → 1.0.0
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/README.md +35 -1
- package/index.js +4 -1
- package/package.json +6 -2
- package/.eslintrc.js +0 -1
- package/.github/workflows/test.yml +0 -37
- package/tests/console.ts +0 -4
- package/tests/jsx-a11y-alt-text.tsx +0 -4
- package/tests/jsx-a11y-interactive-supports-focus.tsx +0 -19
- package/tests/mocks/deprecated-function.ts +0 -6
- package/tests/no-deprecated.ts +0 -5
- package/tests/no-unused-vars.ts +0 -31
- package/tests/react-self-closing-comp.tsx +0 -19
package/README.md
CHANGED
|
@@ -1 +1,35 @@
|
|
|
1
|
-
# eslint-config-matsuri
|
|
1
|
+
# eslint-config-matsuri
|
|
2
|
+
|
|
3
|
+
React/TypeScriptを利用しているリポジトリで共通して使えるESLintのConfigです。
|
|
4
|
+
|
|
5
|
+
当社以外での理由は想定していません。
|
|
6
|
+
|
|
7
|
+
## Motivation
|
|
8
|
+
|
|
9
|
+
- 各リポジトリでESLintの設定を更新しなくていいようにする。
|
|
10
|
+
- 簡単に設定ができるようにする。
|
|
11
|
+
- 頻出するwarningをerrorかoffに分類し、方針を明確にする
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
ESLintを除く依存関係を別途インストールする必要はありません。既に入っている場合は、削除してください。
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
yarn add eslint eslint-config-matsuri
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
設定ファイルは次の記述のみで良くなります。他の記述は削除してください。
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
/** @type {import('eslint').Linter.BaseConfig} */
|
|
25
|
+
const config = {
|
|
26
|
+
extends: ["matsuri"],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
module.exports = config;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Contributing
|
|
33
|
+
|
|
34
|
+
ルールの検証などを行いたい場合は、tests以下にファイルを配置してください。
|
|
35
|
+
Errorが出てほしい記述には、`// eslint-disable-next-line`コメントを付けておくことで、`yarn test`コマンドで確認できるようになります。
|
package/index.js
CHANGED
|
@@ -24,7 +24,6 @@ const config = {
|
|
|
24
24
|
extends: [
|
|
25
25
|
"plugin:react/recommended",
|
|
26
26
|
"plugin:react-hooks/recommended",
|
|
27
|
-
"plugin:import/recommended",
|
|
28
27
|
"plugin:import/typescript",
|
|
29
28
|
"plugin:react/jsx-runtime",
|
|
30
29
|
"plugin:@typescript-eslint/recommended",
|
|
@@ -54,8 +53,12 @@ const config = {
|
|
|
54
53
|
html: true,
|
|
55
54
|
},
|
|
56
55
|
],
|
|
56
|
+
"react/prop-types": "off",
|
|
57
|
+
"react/display-name": "off",
|
|
58
|
+
"react-hooks/exhaustive-deps": "error",
|
|
57
59
|
|
|
58
60
|
"jsx-a11y/click-events-have-key-events": "off",
|
|
61
|
+
"jsx-a11y/no-autofocus": "off",
|
|
59
62
|
},
|
|
60
63
|
},
|
|
61
64
|
],
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-matsuri",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.js"
|
|
8
|
+
],
|
|
6
9
|
"scripts": {
|
|
7
10
|
"test": "eslint . --max-warnings 0"
|
|
8
11
|
},
|
|
@@ -15,6 +18,7 @@
|
|
|
15
18
|
"eslint": ">= 8"
|
|
16
19
|
},
|
|
17
20
|
"devDependencies": {
|
|
21
|
+
"@emotion/react": "^11.9.3",
|
|
18
22
|
"@types/react": "^18.0.14",
|
|
19
23
|
"eslint": "8.18.0",
|
|
20
24
|
"react": "^18.2.0",
|
|
@@ -22,7 +26,7 @@
|
|
|
22
26
|
},
|
|
23
27
|
"dependencies": {
|
|
24
28
|
"@typescript-eslint/eslint-plugin": "5.30.0",
|
|
25
|
-
"@typescript-eslint/parser": "5.30.
|
|
29
|
+
"@typescript-eslint/parser": "5.30.5",
|
|
26
30
|
"eslint-config-prettier": "8.5.0",
|
|
27
31
|
"eslint-import-resolver-typescript": "^3.2.4",
|
|
28
32
|
"eslint-plugin-css-reorder": "0.5.1",
|
package/.eslintrc.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require("./index");
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
name: Test
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: ["main"]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: ["main"]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
test:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
|
|
13
|
-
strategy:
|
|
14
|
-
matrix:
|
|
15
|
-
node-version: [16]
|
|
16
|
-
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v3
|
|
19
|
-
- uses: pnpm/action-setup@v2.2.2
|
|
20
|
-
with:
|
|
21
|
-
version: 7
|
|
22
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
23
|
-
uses: actions/setup-node@v3
|
|
24
|
-
with:
|
|
25
|
-
node-version: ${{ matrix.node-version }}
|
|
26
|
-
- name: Cache node_modules
|
|
27
|
-
id: node_modules_cache_id
|
|
28
|
-
uses: actions/cache@v2
|
|
29
|
-
with:
|
|
30
|
-
key: node-${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
|
|
31
|
-
path: |
|
|
32
|
-
node_modules
|
|
33
|
-
- name: Install dependencies
|
|
34
|
-
run: pnpm install --frozen-lockfile
|
|
35
|
-
env:
|
|
36
|
-
CI: true
|
|
37
|
-
- run: pnpm run test
|
package/tests/console.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const Incorrect = () => (
|
|
2
|
-
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
|
|
3
|
-
<div
|
|
4
|
-
onClick={(event) => {
|
|
5
|
-
window.alert(event.currentTarget);
|
|
6
|
-
}}
|
|
7
|
-
role="button"
|
|
8
|
-
/>
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
export const Correct = () => (
|
|
12
|
-
<div
|
|
13
|
-
onClick={(event) => {
|
|
14
|
-
window.alert(event.currentTarget);
|
|
15
|
-
}}
|
|
16
|
-
role="button"
|
|
17
|
-
tabIndex={0}
|
|
18
|
-
/>
|
|
19
|
-
);
|
package/tests/no-deprecated.ts
DELETED
package/tests/no-unused-vars.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import React, { useState } from "react";
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
-
export const MyComponent = ({ hoge }) => {
|
|
6
|
-
return "Hello, World";
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
-
export const MyComponent2 = ({ hoge, ...props }) => {
|
|
11
|
-
return props;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const MyComponent3 = ({ hoge: _hoge, ...props }) => {
|
|
15
|
-
return props;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
1 + 1;
|
|
20
|
-
} catch (error) {
|
|
21
|
-
1 + 1;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
|
-
(function (foo, bar, baz, qux) {
|
|
26
|
-
return bar;
|
|
27
|
-
})();
|
|
28
|
-
|
|
29
|
-
(function (foo, bar, baz, qux) {
|
|
30
|
-
return qux;
|
|
31
|
-
})();
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const ImaginaryChild = () => <div />;
|
|
2
|
-
|
|
3
|
-
export const IncorrectParentWithImaginaryChild = () => {
|
|
4
|
-
// eslint-disable-next-line react/self-closing-comp
|
|
5
|
-
return <ImaginaryChild></ImaginaryChild>;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const NonImaginaryChild = ({ children }: { children?: string }) => (
|
|
9
|
-
<div>{children}</div>
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
export const CorrectParent = () => {
|
|
13
|
-
return <NonImaginaryChild>Hello</NonImaginaryChild>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const IncorrectParentWithNonImaginaryChild = () => {
|
|
17
|
-
// eslint-disable-next-line react/self-closing-comp
|
|
18
|
-
return <NonImaginaryChild></NonImaginaryChild>;
|
|
19
|
-
};
|