New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

eslint-plugin-react-naming-convention

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-react-naming-convention - npm Package Compare versions

Comparing version

to
1.29.1-beta.5

@@ -8,4 +8,4 @@ 'use strict';

var shared = require('@eslint-react/shared');
var types = require('@typescript-eslint/types');
var tsPattern = require('ts-pattern');
var types = require('@typescript-eslint/types');
var path = require('path');

@@ -58,3 +58,3 @@ var stringTs = require('string-ts');

var name2 = "eslint-plugin-react-naming-convention";
var version = "1.29.1-beta.3";
var version = "1.29.1-beta.5";
var createRule = shared.createRuleForPlugin("naming-convention");

@@ -102,11 +102,10 @@

const opts = options[0];
if (opts == null) {
return defaultOptions[0];
}
if (typeof opts === "string") {
return { ...defaultOptions[0], rule: opts };
}
const defaultOpts = defaultOptions[0];
if (opts == null) return defaultOpts;
return {
...opts,
excepts: opts.excepts?.map((pattern) => new RegExp(pattern, "u")) ?? []
...defaultOpts,
...typeof opts === "string" ? { rule: opts } : {
...opts,
excepts: opts.excepts?.map((pattern) => new RegExp(pattern, "u")) ?? []
}
};

@@ -116,26 +115,17 @@ }

if (name3 == null) return eff._;
const {
allowAllCaps = false,
allowLeadingUnderscore = false,
allowNamespace = false,
excepts,
rule
} = options;
if (excepts.some((regex) => regex.test(name3))) {
return eff._;
if (options.excepts.some((regex) => regex.test(name3))) return eff._;
let normalized = name3.split(".").at(-1) ?? name3;
if (options.allowNamespace) normalized = normalized.replace(":", "");
if (options.allowLeadingUnderscore) normalized = normalized.replace(/^_/, "");
switch (options.rule) {
case "CONSTANT_CASE":
return shared.RE_CONSTANT_CASE.test(normalized) ? eff._ : "useConstantCase";
case "PascalCase":
if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
return options.allowAllCaps ? eff._ : "usePascalCase";
}
return shared.RE_PASCAL_CASE.test(normalized) ? eff._ : "usePascalCase";
default:
return eff._;
}
let normalized = name3.normalize("NFKD").replace(/[\u0300-\u036F]/g, "");
normalized = normalized.split(".").at(-1) ?? normalized;
if (allowNamespace) {
normalized = normalized.replace(":", "");
}
if (allowLeadingUnderscore) {
normalized = normalized.replace(/^_/, "");
}
return tsPattern.match(rule).with("CONSTANT_CASE", () => shared.RE_CONSTANT_CASE.test(normalized) ? eff._ : "useConstantCase").with("PascalCase", () => {
if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
return allowAllCaps ? eff._ : "usePascalCase";
}
return shared.RE_PASCAL_CASE.test(normalized) ? eff._ : "usePascalCase";
}).otherwise(() => eff._);
}

@@ -219,6 +209,6 @@ var component_name_default = createRule({

docs: {
description: "enforce context name to end with 'Context'"
description: "enforces context name to be a valid component name with the suffix 'Context'"
},
messages: {
contextName: "Context name must end with 'Context'."
contextName: "In React 19, you can render '<Context>' as a provider instead of '<Context.Provider>', it's name must be a valid component name with the suffix 'Context'."
},

@@ -236,4 +226,3 @@ schema: []

const name3 = tsPattern.match(id).with({ type: types.AST_NODE_TYPES.Identifier, name: tsPattern.P.select() }, eff.identity).with({ type: types.AST_NODE_TYPES.MemberExpression, property: { name: tsPattern.P.select(tsPattern.P.string) } }, eff.identity).otherwise(() => eff._);
if (name3 == null) return;
if (name3.endsWith("Context")) return;
if (name3 != null && /^[A-Z]/u.test(name3) && name3.endsWith("Context")) return;
context.report({

@@ -240,0 +229,0 @@ messageId: "contextName",

{
"name": "eslint-plugin-react-naming-convention",
"version": "1.29.1-beta.3",
"version": "1.29.1-beta.5",
"description": "ESLint React's ESLint plugin for naming convention related rules.",

@@ -52,8 +52,8 @@ "keywords": [

"ts-pattern": "^5.6.2",
"@eslint-react/ast": "1.29.1-beta.3",
"@eslint-react/core": "1.29.1-beta.3",
"@eslint-react/eff": "1.29.1-beta.3",
"@eslint-react/var": "1.29.1-beta.3",
"@eslint-react/shared": "1.29.1-beta.3",
"@eslint-react/jsx": "1.29.1-beta.3"
"@eslint-react/ast": "1.29.1-beta.5",
"@eslint-react/core": "1.29.1-beta.5",
"@eslint-react/eff": "1.29.1-beta.5",
"@eslint-react/jsx": "1.29.1-beta.5",
"@eslint-react/shared": "1.29.1-beta.5",
"@eslint-react/var": "1.29.1-beta.5"
},

@@ -60,0 +60,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet