eslint-config-matsuri 0.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/.eslintrc.js +1 -0
- package/.github/workflows/test.yml +37 -0
- package/README.md +1 -0
- package/index.js +64 -0
- package/package.json +34 -0
- package/tests/console.ts +4 -0
- package/tests/jsx-a11y-alt-text.tsx +4 -0
- package/tests/jsx-a11y-interactive-supports-focus.tsx +19 -0
- package/tests/mocks/deprecated-function.ts +6 -0
- package/tests/no-deprecated.ts +5 -0
- package/tests/no-unused-vars.ts +31 -0
- package/tests/react-self-closing-comp.tsx +19 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./index");
|
|
@@ -0,0 +1,37 @@
|
|
|
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/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# eslint-config-matsuri
|
package/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** @type {import('eslint').Linter.BaseConfig} */
|
|
2
|
+
const config = {
|
|
3
|
+
reportUnusedDisableDirectives: true,
|
|
4
|
+
env: {
|
|
5
|
+
commonjs: true,
|
|
6
|
+
es2021: true,
|
|
7
|
+
node: true,
|
|
8
|
+
},
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 12,
|
|
11
|
+
},
|
|
12
|
+
extends: ["eslint:recommended"],
|
|
13
|
+
rules: {
|
|
14
|
+
"no-console": ["error", { allow: ["error"] }],
|
|
15
|
+
},
|
|
16
|
+
overrides: [
|
|
17
|
+
{
|
|
18
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
19
|
+
env: {
|
|
20
|
+
browser: true,
|
|
21
|
+
es2021: true,
|
|
22
|
+
},
|
|
23
|
+
plugins: ["css-reorder", "import", "jsx-a11y"],
|
|
24
|
+
extends: [
|
|
25
|
+
"plugin:react/recommended",
|
|
26
|
+
"plugin:react-hooks/recommended",
|
|
27
|
+
"plugin:import/recommended",
|
|
28
|
+
"plugin:import/typescript",
|
|
29
|
+
"plugin:react/jsx-runtime",
|
|
30
|
+
"plugin:@typescript-eslint/recommended",
|
|
31
|
+
"plugin:jsx-a11y/recommended",
|
|
32
|
+
"prettier",
|
|
33
|
+
],
|
|
34
|
+
settings: {
|
|
35
|
+
react: {
|
|
36
|
+
version: "detect",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
rules: {
|
|
40
|
+
"import/no-deprecated": "error",
|
|
41
|
+
|
|
42
|
+
"css-reorder/property-reorder": "error",
|
|
43
|
+
|
|
44
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
45
|
+
"@typescript-eslint/no-unused-vars": [
|
|
46
|
+
"error",
|
|
47
|
+
{ vars: "all", argsIgnorePattern: "^_" },
|
|
48
|
+
],
|
|
49
|
+
|
|
50
|
+
"react/self-closing-comp": [
|
|
51
|
+
"error",
|
|
52
|
+
{
|
|
53
|
+
component: true,
|
|
54
|
+
html: true,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
|
|
58
|
+
"jsx-a11y/click-events-have-key-events": "off",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
module.exports = config;
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-config-matsuri",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "eslint . --max-warnings 0"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "hrdtbs",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"registry": "https://registry.npmjs.org/"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"eslint": ">= 8"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/react": "^18.0.14",
|
|
19
|
+
"eslint": "8.18.0",
|
|
20
|
+
"react": "^18.2.0",
|
|
21
|
+
"typescript": "^4.7.4"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "5.30.0",
|
|
25
|
+
"@typescript-eslint/parser": "5.30.0",
|
|
26
|
+
"eslint-config-prettier": "8.5.0",
|
|
27
|
+
"eslint-import-resolver-typescript": "^3.2.4",
|
|
28
|
+
"eslint-plugin-css-reorder": "0.5.1",
|
|
29
|
+
"eslint-plugin-import": "^2.26.0",
|
|
30
|
+
"eslint-plugin-jsx-a11y": "^6.6.0",
|
|
31
|
+
"eslint-plugin-react": "7.30.1",
|
|
32
|
+
"eslint-plugin-react-hooks": "4.6.0"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/tests/console.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
})();
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
};
|