eslint-plugin-mgw-eslint-rules 2.2.39 → 2.2.41

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.ts CHANGED
@@ -1,14 +1,3 @@
1
- declare const _default: {
2
- rules: {
3
- 'no-inline-styles': import("eslint").Rule.RuleModule;
4
- };
5
- configs: {
6
- recommended: {
7
- plugins: string[];
8
- rules: {
9
- 'react-props-restrictions/no-inline-styles': string;
10
- };
11
- };
12
- };
1
+ export declare const rules: {
2
+ 'case-first-declarations': import("eslint").Rule.RuleModule;
13
3
  };
14
- export = _default;
package/dist/index.js CHANGED
@@ -2,17 +2,20 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
- const no_inline_styles_1 = __importDefault(require("./rules/no-inline-styles"));
6
- module.exports = {
7
- rules: {
8
- 'no-inline-styles': no_inline_styles_1.default
9
- },
10
- configs: {
11
- recommended: {
12
- plugins: ['react-props-restrictions'],
13
- rules: {
14
- 'react-props-restrictions/no-inline-styles': 'error'
15
- }
16
- }
17
- }
18
- };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.rules = void 0;
7
+ const case_first_declarations_1 = __importDefault(require("./rules/case-first-declarations"));
8
+ exports.rules = { 'case-first-declarations': case_first_declarations_1.default };
9
+ // export = {
10
+ // rules: {
11
+ // 'no-inline-styles': noInlineStyles
12
+ // },
13
+ // configs: {
14
+ // recommended: {
15
+ // plugins: ['react-props-restrictions'],
16
+ // rules: {
17
+ // 'react-props-restrictions/no-inline-styles': 'error'
18
+ // }
19
+ // }
20
+ // }
21
+ // };
@@ -1,12 +1,3 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
- export type MessageIds = 'lowercase' | 'uppercase';
3
- export type Options = [
4
- {
5
- preferredCase?: 'lower' | 'upper';
6
- }
7
- ];
8
- export interface MyPluginDocs {
9
- recommended: boolean;
10
- }
11
- export declare const RULE_NAME = "case-first-declarations";
12
- export declare const rule: ESLintUtils.RuleModule<MessageIds, Options, MyPluginDocs, ESLintUtils.RuleListener>;
1
+ import { Rule } from 'eslint';
2
+ declare const caseFirstDeclarations: Rule.RuleModule;
3
+ export default caseFirstDeclarations;
@@ -1,42 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rule = exports.RULE_NAME = void 0;
4
- // rules/case-first-declarations.ts
5
- const utils_1 = require("@typescript-eslint/utils");
6
- exports.RULE_NAME = 'case-first-declarations';
7
- const createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://github.com/developpement-megao/mgw-eslint-rules/docs/rule/${name}.md`);
8
- // Type: RuleModule<MessageIds, ...>
9
- exports.rule = createRule({
10
- create(context, options) {
11
- const preferredCase = options[0].preferredCase;
12
- // On va tester si on a un lower caractère en premier si option upper
13
- const testRegexp = preferredCase === 'upper' ? /^[a-z]/ : /^[A-Z]/;
14
- return {
15
- FunctionDeclaration(node) {
16
- if (node.id != null) {
17
- // On teste si le premier caractère est en lower (pour rule option upper)
18
- if (testRegexp.test(node.id.name)) {
19
- // Premier caractère lower (pour rule option upper) donc on renvoit le message d'erreur upper
20
- context.report({
21
- messageId: preferredCase === 'upper' ? 'uppercase' : 'lowercase',
22
- node: node.id
23
- });
24
- }
25
- }
26
- }
27
- };
28
- },
29
- name: exports.RULE_NAME,
3
+ const caseFirstDeclarations = {
30
4
  meta: {
5
+ type: 'suggestion',
31
6
  docs: {
32
- description: 'Function declaration names should start with an upper-case letter.',
7
+ description: 'Function declaration names should start with an upper-case or lower-case letter.',
8
+ category: 'Best Practices',
33
9
  recommended: true
34
10
  },
35
- messages: {
36
- lowercase: 'Start this name with an lower-case letter.',
37
- uppercase: 'Start this name with an upper-case letter.'
38
- },
39
- type: 'suggestion',
40
11
  schema: [
41
12
  {
42
13
  type: 'object',
@@ -48,11 +19,31 @@ exports.rule = createRule({
48
19
  },
49
20
  additionalProperties: false
50
21
  }
51
- ]
52
- },
53
- defaultOptions: [
54
- {
55
- preferredCase: 'lower'
22
+ ],
23
+ messages: {
24
+ lowercase: 'Start this name with an lower-case letter.',
25
+ uppercase: 'Start this name with an upper-case letter.'
56
26
  }
57
- ]
58
- });
27
+ },
28
+ create(context) {
29
+ return {
30
+ FunctionDeclaration(node) {
31
+ if (node.id != null) {
32
+ const options = context.options[0] || {};
33
+ const preferredCase = options.preferredCase;
34
+ // On va tester si on a un lower caractère en premier si option upper
35
+ const testRegexp = preferredCase === 'upper' ? /^[a-z]/ : /^[A-Z]/;
36
+ // On teste si le premier caractère est en lower (pour rule option upper)
37
+ if (testRegexp.test(node.id.name)) {
38
+ // Premier caractère lower (pour rule option upper) donc on renvoit le message d'erreur upper
39
+ context.report({
40
+ messageId: preferredCase === 'upper' ? 'uppercase' : 'lowercase',
41
+ node: node.id
42
+ });
43
+ }
44
+ }
45
+ }
46
+ };
47
+ }
48
+ };
49
+ exports.default = caseFirstDeclarations;
@@ -30,8 +30,7 @@ exports.enforceAngularSignalCall = createRule({
30
30
  const checker = services.program.getTypeChecker();
31
31
  return {
32
32
  Identifier(node) {
33
- var _a;
34
- const variableNode = (_a = services.esTreeNodeToTSNodeMap) === null || _a === void 0 ? void 0 : _a.get(node);
33
+ const variableNode = services.esTreeNodeToTSNodeMap?.get(node);
35
34
  if (variableNode) {
36
35
  const type = checker.getTypeAtLocation(variableNode);
37
36
  const typeName = checker.typeToString(type);
@@ -34,7 +34,7 @@ const noInlineStyles = {
34
34
  const allowedComponents = options.allowInSpecificComponents || [];
35
35
  // Find the name of the parent component
36
36
  const jsxElement = node.parent;
37
- const componentName = (jsxElement === null || jsxElement === void 0 ? void 0 : jsxElement.type) === 'JSXOpeningElement' && jsxElement.name.type === 'JSXIdentifier' ? jsxElement.name.name : '';
37
+ const componentName = jsxElement?.type === 'JSXOpeningElement' && jsxElement.name.type === 'JSXIdentifier' ? jsxElement.name.name : '';
38
38
  // Allow inline styles in specific components defined in the options
39
39
  if (componentName && allowedComponents.includes(componentName)) {
40
40
  return;
@@ -61,18 +61,17 @@ exports.namingConvention = createRule({
61
61
  create(context, options) {
62
62
  return {
63
63
  "ElementAttribute[name.name='class'], ElementAttribute[name.name='id']"(node) {
64
- var _a, _b, _c;
65
- const value = (_a = node.value) === null || _a === void 0 ? void 0 : _a.value;
64
+ const value = node.value?.value;
66
65
  if (!value) {
67
66
  return;
68
67
  }
69
68
  // 'class' ou 'id'
70
- const attributeName = (_b = node.name) === null || _b === void 0 ? void 0 : _b.name;
69
+ const attributeName = node.name?.name;
71
70
  if (!attributeName) {
72
71
  return;
73
72
  }
74
73
  // Récupère les formats autorisés pour ce sélecteur
75
- const optionsFormats = (_c = options.find((opt) => opt.selector === attributeName)) === null || _c === void 0 ? void 0 : _c.formats;
74
+ const optionsFormats = options.find((opt) => opt.selector === attributeName)?.formats;
76
75
  if (!optionsFormats) {
77
76
  return;
78
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-mgw-eslint-rules",
3
- "version": "2.2.39",
3
+ "version": "2.2.41",
4
4
  "description": "Custom eslint rules of MegaO",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -48,7 +48,6 @@
48
48
  "@angular/cli": "^19.2.19",
49
49
  "@angular/compiler": "^19.2.18",
50
50
  "@types/eslint": "^9.6.1",
51
- "@types/estree-jsx": "^1.0.5",
52
51
  "@types/jest": "^30.0.0",
53
52
  "@types/node": "^25.2.2",
54
53
  "@typescript-eslint/eslint-plugin": "^8.46.4",