eslint-plugin-react-naming-convention 1.28.1-next.6 → 1.29.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/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +41 -8
- package/dist/index.mjs +44 -11
- package/package.json +7 -6
package/dist/index.d.mts
CHANGED
|
@@ -24,6 +24,7 @@ declare const _default: {
|
|
|
24
24
|
excepts?: readonly string[];
|
|
25
25
|
rule?: "CONSTANT_CASE" | "PascalCase";
|
|
26
26
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
27
|
+
readonly "context-name": _typescript_eslint_utils_ts_eslint.RuleModule<"contextName", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
27
28
|
readonly filename: _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, readonly [("PascalCase" | "camelCase" | "kebab-case" | "snake_case") | {
|
|
28
29
|
excepts?: readonly string[];
|
|
29
30
|
extensions?: readonly string[];
|
|
@@ -58,6 +59,7 @@ declare const _default: {
|
|
|
58
59
|
excepts?: readonly string[];
|
|
59
60
|
rule?: "CONSTANT_CASE" | "PascalCase";
|
|
60
61
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
62
|
+
readonly "context-name": _typescript_eslint_utils_ts_eslint.RuleModule<"contextName", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
61
63
|
readonly filename: _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, readonly [("PascalCase" | "camelCase" | "kebab-case" | "snake_case") | {
|
|
62
64
|
excepts?: readonly string[];
|
|
63
65
|
extensions?: readonly string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare const _default: {
|
|
|
24
24
|
excepts?: readonly string[];
|
|
25
25
|
rule?: "CONSTANT_CASE" | "PascalCase";
|
|
26
26
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
27
|
+
readonly "context-name": _typescript_eslint_utils_ts_eslint.RuleModule<"contextName", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
27
28
|
readonly filename: _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, readonly [("PascalCase" | "camelCase" | "kebab-case" | "snake_case") | {
|
|
28
29
|
excepts?: readonly string[];
|
|
29
30
|
extensions?: readonly string[];
|
|
@@ -58,6 +59,7 @@ declare const _default: {
|
|
|
58
59
|
excepts?: readonly string[];
|
|
59
60
|
rule?: "CONSTANT_CASE" | "PascalCase";
|
|
60
61
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
62
|
+
readonly "context-name": _typescript_eslint_utils_ts_eslint.RuleModule<"contextName", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
61
63
|
readonly filename: _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, readonly [("PascalCase" | "camelCase" | "kebab-case" | "snake_case") | {
|
|
62
64
|
excepts?: readonly string[];
|
|
63
65
|
extensions?: readonly string[];
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@ var eff = require('@eslint-react/eff');
|
|
|
6
6
|
var JSX = require('@eslint-react/jsx');
|
|
7
7
|
var shared = require('@eslint-react/shared');
|
|
8
8
|
var tsPattern = require('ts-pattern');
|
|
9
|
+
var types = require('@typescript-eslint/types');
|
|
9
10
|
var path = require('path');
|
|
10
11
|
var stringTs = require('string-ts');
|
|
11
|
-
var types = require('@typescript-eslint/types');
|
|
12
12
|
|
|
13
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
|
|
@@ -51,7 +51,7 @@ var rules = {};
|
|
|
51
51
|
|
|
52
52
|
// package.json
|
|
53
53
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
54
|
-
var version = "1.
|
|
54
|
+
var version = "1.29.0";
|
|
55
55
|
var createRule = shared.createRuleForPlugin("naming-convention");
|
|
56
56
|
|
|
57
57
|
// src/rules/component-name.ts
|
|
@@ -204,7 +204,39 @@ var component_name_default = createRule({
|
|
|
204
204
|
},
|
|
205
205
|
defaultOptions
|
|
206
206
|
});
|
|
207
|
-
var RULE_NAME2 = "
|
|
207
|
+
var RULE_NAME2 = "context-name";
|
|
208
|
+
var context_name_default = createRule({
|
|
209
|
+
meta: {
|
|
210
|
+
type: "problem",
|
|
211
|
+
docs: {
|
|
212
|
+
description: "enforce context name to end with `Context`."
|
|
213
|
+
},
|
|
214
|
+
messages: {
|
|
215
|
+
contextName: "Context name must end with `Context`."
|
|
216
|
+
},
|
|
217
|
+
schema: []
|
|
218
|
+
},
|
|
219
|
+
name: RULE_NAME2,
|
|
220
|
+
create(context) {
|
|
221
|
+
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
222
|
+
return {
|
|
223
|
+
CallExpression(node) {
|
|
224
|
+
if (!core.isCreateContextCall(context, node)) return;
|
|
225
|
+
const id = core.getInstanceId(node);
|
|
226
|
+
if (id == null) return;
|
|
227
|
+
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._);
|
|
228
|
+
if (name3 == null) return;
|
|
229
|
+
if (name3.endsWith("Context")) return;
|
|
230
|
+
context.report({
|
|
231
|
+
messageId: "contextName",
|
|
232
|
+
node: id
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
},
|
|
237
|
+
defaultOptions: []
|
|
238
|
+
});
|
|
239
|
+
var RULE_NAME3 = "filename";
|
|
208
240
|
var defaultOptions2 = [
|
|
209
241
|
{
|
|
210
242
|
excepts: ["^index$"],
|
|
@@ -254,7 +286,7 @@ var filename_default = createRule({
|
|
|
254
286
|
},
|
|
255
287
|
schema: schema2
|
|
256
288
|
},
|
|
257
|
-
name:
|
|
289
|
+
name: RULE_NAME3,
|
|
258
290
|
create(context) {
|
|
259
291
|
const options = context.options[0] ?? defaultOptions2[0];
|
|
260
292
|
const rule = typeof options === "string" ? options : options.rule ?? "PascalCase";
|
|
@@ -291,7 +323,7 @@ var filename_default = createRule({
|
|
|
291
323
|
},
|
|
292
324
|
defaultOptions: defaultOptions2
|
|
293
325
|
});
|
|
294
|
-
var
|
|
326
|
+
var RULE_NAME4 = "filename-extension";
|
|
295
327
|
var defaultOptions3 = [{
|
|
296
328
|
allow: "as-needed",
|
|
297
329
|
extensions: [".jsx", ".tsx"],
|
|
@@ -340,7 +372,7 @@ var filename_extension_default = createRule({
|
|
|
340
372
|
},
|
|
341
373
|
schema: schema3
|
|
342
374
|
},
|
|
343
|
-
name:
|
|
375
|
+
name: RULE_NAME4,
|
|
344
376
|
create(context) {
|
|
345
377
|
const options = context.options[0] ?? defaultOptions3[0];
|
|
346
378
|
const allow = eff.isObject(options) ? options.allow : options;
|
|
@@ -387,7 +419,7 @@ var filename_extension_default = createRule({
|
|
|
387
419
|
},
|
|
388
420
|
defaultOptions: defaultOptions3
|
|
389
421
|
});
|
|
390
|
-
var
|
|
422
|
+
var RULE_NAME5 = "use-state";
|
|
391
423
|
var RULE_FEATURES = [
|
|
392
424
|
"CHK"
|
|
393
425
|
];
|
|
@@ -403,7 +435,7 @@ var use_state_default = createRule({
|
|
|
403
435
|
},
|
|
404
436
|
schema: []
|
|
405
437
|
},
|
|
406
|
-
name:
|
|
438
|
+
name: RULE_NAME5,
|
|
407
439
|
create(context) {
|
|
408
440
|
return {
|
|
409
441
|
"CallExpression[callee.name='useState']"(node) {
|
|
@@ -452,6 +484,7 @@ var plugin = {
|
|
|
452
484
|
},
|
|
453
485
|
rules: {
|
|
454
486
|
"component-name": component_name_default,
|
|
487
|
+
"context-name": context_name_default,
|
|
455
488
|
filename: filename_default,
|
|
456
489
|
"filename-extension": filename_extension_default,
|
|
457
490
|
"use-state": use_state_default
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as AST from '@eslint-react/ast';
|
|
2
|
-
import { useComponentCollector, useComponentCollectorLegacy, getInstanceId } from '@eslint-react/core';
|
|
3
|
-
import {
|
|
2
|
+
import { useComponentCollector, useComponentCollectorLegacy, isCreateContextCall, getInstanceId } from '@eslint-react/core';
|
|
3
|
+
import { identity, _, isObject } from '@eslint-react/eff';
|
|
4
4
|
import * as JSX from '@eslint-react/jsx';
|
|
5
5
|
import { createRuleForPlugin, RE_CONSTANT_CASE, RE_PASCAL_CASE, RE_CAMEL_CASE, RE_KEBAB_CASE, RE_SNAKE_CASE } from '@eslint-react/shared';
|
|
6
|
-
import { match } from 'ts-pattern';
|
|
6
|
+
import { match, P } from 'ts-pattern';
|
|
7
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
7
8
|
import path from 'node:path';
|
|
8
9
|
import { snakeCase, pascalCase, camelCase, kebabCase } from 'string-ts';
|
|
9
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
10
10
|
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
12
12
|
var __export = (target, all) => {
|
|
@@ -25,7 +25,7 @@ var rules = {};
|
|
|
25
25
|
|
|
26
26
|
// package.json
|
|
27
27
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
28
|
-
var version = "1.
|
|
28
|
+
var version = "1.29.0";
|
|
29
29
|
var createRule = createRuleForPlugin("naming-convention");
|
|
30
30
|
|
|
31
31
|
// src/rules/component-name.ts
|
|
@@ -178,7 +178,39 @@ var component_name_default = createRule({
|
|
|
178
178
|
},
|
|
179
179
|
defaultOptions
|
|
180
180
|
});
|
|
181
|
-
var RULE_NAME2 = "
|
|
181
|
+
var RULE_NAME2 = "context-name";
|
|
182
|
+
var context_name_default = createRule({
|
|
183
|
+
meta: {
|
|
184
|
+
type: "problem",
|
|
185
|
+
docs: {
|
|
186
|
+
description: "enforce context name to end with `Context`."
|
|
187
|
+
},
|
|
188
|
+
messages: {
|
|
189
|
+
contextName: "Context name must end with `Context`."
|
|
190
|
+
},
|
|
191
|
+
schema: []
|
|
192
|
+
},
|
|
193
|
+
name: RULE_NAME2,
|
|
194
|
+
create(context) {
|
|
195
|
+
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
196
|
+
return {
|
|
197
|
+
CallExpression(node) {
|
|
198
|
+
if (!isCreateContextCall(context, node)) return;
|
|
199
|
+
const id = getInstanceId(node);
|
|
200
|
+
if (id == null) return;
|
|
201
|
+
const name3 = match(id).with({ type: AST_NODE_TYPES.Identifier, name: P.select() }, identity).with({ type: AST_NODE_TYPES.MemberExpression, property: { name: P.select(P.string) } }, identity).otherwise(() => _);
|
|
202
|
+
if (name3 == null) return;
|
|
203
|
+
if (name3.endsWith("Context")) return;
|
|
204
|
+
context.report({
|
|
205
|
+
messageId: "contextName",
|
|
206
|
+
node: id
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
defaultOptions: []
|
|
212
|
+
});
|
|
213
|
+
var RULE_NAME3 = "filename";
|
|
182
214
|
var defaultOptions2 = [
|
|
183
215
|
{
|
|
184
216
|
excepts: ["^index$"],
|
|
@@ -228,7 +260,7 @@ var filename_default = createRule({
|
|
|
228
260
|
},
|
|
229
261
|
schema: schema2
|
|
230
262
|
},
|
|
231
|
-
name:
|
|
263
|
+
name: RULE_NAME3,
|
|
232
264
|
create(context) {
|
|
233
265
|
const options = context.options[0] ?? defaultOptions2[0];
|
|
234
266
|
const rule = typeof options === "string" ? options : options.rule ?? "PascalCase";
|
|
@@ -265,7 +297,7 @@ var filename_default = createRule({
|
|
|
265
297
|
},
|
|
266
298
|
defaultOptions: defaultOptions2
|
|
267
299
|
});
|
|
268
|
-
var
|
|
300
|
+
var RULE_NAME4 = "filename-extension";
|
|
269
301
|
var defaultOptions3 = [{
|
|
270
302
|
allow: "as-needed",
|
|
271
303
|
extensions: [".jsx", ".tsx"],
|
|
@@ -314,7 +346,7 @@ var filename_extension_default = createRule({
|
|
|
314
346
|
},
|
|
315
347
|
schema: schema3
|
|
316
348
|
},
|
|
317
|
-
name:
|
|
349
|
+
name: RULE_NAME4,
|
|
318
350
|
create(context) {
|
|
319
351
|
const options = context.options[0] ?? defaultOptions3[0];
|
|
320
352
|
const allow = isObject(options) ? options.allow : options;
|
|
@@ -361,7 +393,7 @@ var filename_extension_default = createRule({
|
|
|
361
393
|
},
|
|
362
394
|
defaultOptions: defaultOptions3
|
|
363
395
|
});
|
|
364
|
-
var
|
|
396
|
+
var RULE_NAME5 = "use-state";
|
|
365
397
|
var RULE_FEATURES = [
|
|
366
398
|
"CHK"
|
|
367
399
|
];
|
|
@@ -377,7 +409,7 @@ var use_state_default = createRule({
|
|
|
377
409
|
},
|
|
378
410
|
schema: []
|
|
379
411
|
},
|
|
380
|
-
name:
|
|
412
|
+
name: RULE_NAME5,
|
|
381
413
|
create(context) {
|
|
382
414
|
return {
|
|
383
415
|
"CallExpression[callee.name='useState']"(node) {
|
|
@@ -426,6 +458,7 @@ var plugin = {
|
|
|
426
458
|
},
|
|
427
459
|
rules: {
|
|
428
460
|
"component-name": component_name_default,
|
|
461
|
+
"context-name": context_name_default,
|
|
429
462
|
filename: filename_default,
|
|
430
463
|
"filename-extension": filename_extension_default,
|
|
431
464
|
"use-state": use_state_default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -49,11 +49,12 @@
|
|
|
49
49
|
"@typescript-eslint/utils": "^8.25.0",
|
|
50
50
|
"string-ts": "^2.2.1",
|
|
51
51
|
"ts-pattern": "^5.6.2",
|
|
52
|
-
"@eslint-react/ast": "1.
|
|
53
|
-
"@eslint-react/core": "1.
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
52
|
+
"@eslint-react/ast": "1.29.0",
|
|
53
|
+
"@eslint-react/core": "1.29.0",
|
|
54
|
+
"@eslint-react/eff": "1.29.0",
|
|
55
|
+
"@eslint-react/jsx": "1.29.0",
|
|
56
|
+
"@eslint-react/shared": "1.29.0",
|
|
57
|
+
"@eslint-react/var": "1.29.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@types/react": "^19.0.10",
|