Skip to content

Commit 37cd3cb

Browse files
committed
refactor(plugins/naming-convention): refactor filename rule to follow eslint glob scope instead of the extensions option
1 parent 4afc171 commit 37cd3cb

File tree

1 file changed

+9
-9
lines changed
  • packages/plugins/eslint-plugin-react-naming-convention/src/rules

1 file changed

+9
-9
lines changed

packages/plugins/eslint-plugin-react-naming-convention/src/rules/filename.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from "node:path";
22

33
import { RE_CAMEL_CASE, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE } from "@eslint-react/shared";
4-
import { isObject, isString } from "@eslint-react/tools";
4+
import { isString } from "@eslint-react/tools";
55
import type { JSONSchema4 } from "@typescript-eslint/utils/json-schema";
66
import { camelCase, kebabCase, pascalCase, snakeCase } from "string-ts";
77
import { match } from "ts-pattern";
@@ -38,7 +38,7 @@ type Options = readonly [
3838
const defaultOptions = [
3939
{
4040
excepts: ["^index$"],
41-
extensions: [".jsx", ".tsx"],
41+
extensions: [".js", ".jsx", ".ts", ".tsx"],
4242
rule: "PascalCase",
4343
},
4444
] as const satisfies Options;
@@ -93,15 +93,15 @@ export default createRule<Options, MessageID>({
9393
const rule = isString(options) ? options : options.rule ?? "PascalCase";
9494
// eslint-disable-next-line @typescript-eslint/no-deprecated
9595
const excepts = isString(options) ? [] : options.excepts ?? [];
96-
const extensions = isObject(options) && "extensions" in options
97-
// eslint-disable-next-line @typescript-eslint/no-deprecated
98-
? options.extensions
99-
: defaultOptions[0].extensions;
96+
// const extensions = isObject(options) && "extensions" in options
97+
// // eslint-disable-next-line @typescript-eslint/no-deprecated
98+
// ? options.extensions
99+
// : defaultOptions[0].extensions;
100100

101101
const filename = context.filename;
102-
const fileNameExt = filename
103-
.slice(filename.lastIndexOf("."));
104-
if (!extensions.includes(fileNameExt)) return {};
102+
// const fileNameExt = filename
103+
// .slice(filename.lastIndexOf("."));
104+
// if (!extensions.includes(fileNameExt)) return {};
105105

106106
function validate(name: string, casing: Case = rule, ignores: readonly string[] = excepts) {
107107
if (ignores.map((pattern) => new RegExp(pattern, "u")).some((pattern) => pattern.test(name))) {

0 commit comments

Comments
 (0)