Skip to content

Commit

Permalink
🔧 Update eslintrc
Browse files Browse the repository at this point in the history
  • Loading branch information
lightsound committed May 29, 2022
1 parent 0e558d3 commit 8ca09ab
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = {
"error",
{ paths: [{ name: "react", importNames: ["default"] }] },
],

// react
"react/display-name": "error",
"react/jsx-handler-names": [
Expand All @@ -43,13 +44,15 @@ module.exports = {
},
],
"react/destructuring-assignment": ["error", "always"],

// sort
"import/newline-after-import": "error",
"import/no-default-export": "error",
"import-access/jsdoc": "error",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"sort-destructure-keys/sort-destructure-keys": 2,

// @typescript-eslint
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
Expand All @@ -64,8 +67,23 @@ module.exports = {
],
"@typescript-eslint/naming-convention": [
"error",
{ selector: ["typeAlias", "typeParameter"], format: ["PascalCase"] },
{ selector: ["property", "method"], format: ["camelCase"] },
// typeLike (class, interface, typeAlias, enum, typeParameter) は PascalCase
{
selector: ["typeLike"],
format: ["PascalCase"],
},
// function, method (classMethod, objectLiteralMethod, typeMethod) は camelCase
{
selector: ["function", "method"],
format: ["camelCase"],
},
// function 以外の variable, parameter は camelCase
{
selector: ["variable", "parameter"],
types: ["boolean", "string", "number", "array"],
format: ["camelCase"],
},
// boolean の variable は特定の prefix をつけた状態で PascalCase
{
selector: "variable",
types: ["boolean"],
Expand All @@ -74,6 +92,7 @@ module.exports = {
filter: { regex: "^_", match: false },
},
],

// jsx-a11y
"jsx-a11y/no-autofocus": "off",
"jsx-a11y/anchor-is-valid": [
Expand All @@ -88,34 +107,13 @@ module.exports = {
overrides: [
{
files: [
"playwright.config.ts",
"pages/**/*.tsx",
"pages/api/**/*.ts",
"next.config.mjs",
"playwright.config.ts",
],
rules: { "import/no-default-export": "off" },
},
{
files: [
"pages/**/*.tsx",
"pages/api/**/*.ts",
"next.config.mjs",
"src/type/**/*.d.ts",
],
rules: {
"@typescript-eslint/naming-convention": [
"error",
{ selector: ["typeAlias", "typeParameter"], format: ["PascalCase"] },
{ selector: ["classProperty", "method"], format: ["camelCase"] },
{
selector: "variable",
types: ["boolean"],
format: ["PascalCase"],
prefix: ["is", "has", "should"],
},
],
},
},
{
files: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
extends: ["plugin:testing-library/react"],
Expand Down

0 comments on commit 8ca09ab

Please sign in to comment.