|
| 1 | +import eslint from '@eslint/js'; |
| 2 | +import tseslint from 'typescript-eslint'; |
| 3 | +import globals from 'globals'; |
| 4 | +import eslintConfigPrettier from 'eslint-config-prettier'; |
| 5 | +import eslintPluginPrettier from 'eslint-plugin-prettier'; |
| 6 | + |
| 7 | +export default tseslint.config( |
| 8 | + eslint.configs.recommended, |
| 9 | + tseslint.configs.eslintRecommended, |
| 10 | + ...tseslint.configs.recommended, |
| 11 | + ...tseslint.configs.recommendedTypeChecked, |
| 12 | + eslintConfigPrettier, |
| 13 | + { |
| 14 | + languageOptions: |
| 15 | + { |
| 16 | + parserOptions: |
| 17 | + { |
| 18 | + sourceType: 'module', |
| 19 | + ecmaVersion: 2020, |
| 20 | + project: './tsconfig.json', |
| 21 | + }, |
| 22 | + globals: |
| 23 | + { |
| 24 | + ...globals.browser, |
| 25 | + }, |
| 26 | + }, |
| 27 | + plugins: |
| 28 | + { |
| 29 | + 'prettier': eslintPluginPrettier, |
| 30 | + }, |
| 31 | + rules: |
| 32 | + { |
| 33 | + 'prettier/prettier': [ |
| 34 | + 'error', |
| 35 | + { |
| 36 | + singleQuote: true, |
| 37 | + trailingComma: 'none', |
| 38 | + arrowParens: 'avoid', |
| 39 | + } |
| 40 | + ], |
| 41 | + camelcase: 'off', |
| 42 | + '@typescript-eslint/naming-convention': [ |
| 43 | + 'warn', |
| 44 | + { |
| 45 | + selector: 'default', |
| 46 | + format: ['camelCase'], |
| 47 | + }, |
| 48 | + { |
| 49 | + selector: 'import', |
| 50 | + format: ['PascalCase'], |
| 51 | + }, |
| 52 | + { |
| 53 | + selector: 'variable', |
| 54 | + format: [], |
| 55 | + custom: { |
| 56 | + // 指定の文字列で始まるものと特定の文字を含むものは許容 |
| 57 | + regex: '^[A-Z]|^csm|^iterator|Shader', |
| 58 | + match: true, |
| 59 | + }, |
| 60 | + modifiers: ['exported', 'const'], |
| 61 | + }, |
| 62 | + { |
| 63 | + selector: 'variable', |
| 64 | + format: ['camelCase'], |
| 65 | + }, |
| 66 | + { |
| 67 | + selector: 'variable', |
| 68 | + format: [], |
| 69 | + custom: { |
| 70 | + // 指定の文字列で始まるものは許容 |
| 71 | + regex: '^[A-Z]|^s_', |
| 72 | + match: true, |
| 73 | + }, |
| 74 | + modifiers: ['global'] |
| 75 | + }, |
| 76 | + { |
| 77 | + selector: 'enum', |
| 78 | + format: ['PascalCase'], |
| 79 | + }, |
| 80 | + { |
| 81 | + selector: 'enumMember', |
| 82 | + format: [], |
| 83 | + custom: { |
| 84 | + // 大文字から始まること |
| 85 | + regex: '^[A-Z]', |
| 86 | + match: true, |
| 87 | + } |
| 88 | + }, |
| 89 | + { |
| 90 | + selector: 'classProperty', |
| 91 | + format: ['PascalCase'], |
| 92 | + modifiers: ['static', 'readonly'] |
| 93 | + }, |
| 94 | + { |
| 95 | + selector: 'classProperty', |
| 96 | + format: ['camelCase'], |
| 97 | + leadingUnderscore: 'allow', |
| 98 | + }, |
| 99 | + { |
| 100 | + selector: 'class', |
| 101 | + format: [], |
| 102 | + custom: { |
| 103 | + // 指定の文字列で始まるか、指定の文字列で終わること |
| 104 | + regex: '^[A-Z]|^csm|^iterator|_WebGL$', |
| 105 | + match: true, |
| 106 | + } |
| 107 | + }, |
| 108 | + { |
| 109 | + selector: 'interface', |
| 110 | + format: ['camelCase', 'PascalCase'], |
| 111 | + }, |
| 112 | + { |
| 113 | + selector: 'parameter', |
| 114 | + format: ['camelCase'], |
| 115 | + }, |
| 116 | + { |
| 117 | + selector: 'classMethod', |
| 118 | + format: ['camelCase'], |
| 119 | + }, |
| 120 | + { |
| 121 | + selector: 'objectLiteralProperty', |
| 122 | + format: ['camelCase', 'PascalCase'], |
| 123 | + }, |
| 124 | + { |
| 125 | + selector: 'typeAlias', |
| 126 | + format: [], |
| 127 | + custom: { |
| 128 | + // 指定の文字列で始まるものは許容 |
| 129 | + regex: '^[A-Z]|^[a-z]|^CSM_|^csm|^iterator', |
| 130 | + match: true, |
| 131 | + }, |
| 132 | + modifiers: ['exported'] |
| 133 | + }, |
| 134 | + { |
| 135 | + selector: 'typeAlias', |
| 136 | + format: ['camelCase'], |
| 137 | + }, |
| 138 | + { |
| 139 | + selector: 'typeParameter', |
| 140 | + format: [], |
| 141 | + custom: |
| 142 | + { |
| 143 | + // 「大文字+アンダースコア以外の文字」、あるいは「大文字1文字」 |
| 144 | + // あるいは、「`T`+アンダースコア」で始まる場合 |
| 145 | + regex: '^[A-Z][^_]|^[A-Z]|^T_$', |
| 146 | + match: true, |
| 147 | + }, |
| 148 | + leadingUnderscore: 'allow', |
| 149 | + }, |
| 150 | + ], // @typescript-eslint/naming-convention |
| 151 | + '@typescript-eslint/no-use-before-define': 'off', |
| 152 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 153 | + '@typescript-eslint/unbound-method': 'off', |
| 154 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 155 | + '@typescript-eslint/no-unsafe-return': 'off', |
| 156 | + '@typescript-eslint/no-floating-promises': 'off', |
| 157 | + '@typescript-eslint/no-unused-vars': 'off', |
| 158 | + '@typescript-eslint/no-explicit-any': 'off', |
| 159 | + }, |
| 160 | + }, |
| 161 | + { |
| 162 | + // ignores property はなぜか単独で指定していないと効果がない。 |
| 163 | + ignores: [ |
| 164 | + '**/*.*', |
| 165 | + '!src/**/*.ts', |
| 166 | + ], |
| 167 | + }, |
| 168 | +); |
0 commit comments