@alextheman/eslint-plugin 1.9.0 → 1.10.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.cjs CHANGED
@@ -3706,7 +3706,7 @@ module.exports = __toCommonJS(index_exports);
3706
3706
 
3707
3707
  // package.json
3708
3708
  var name = "@alextheman/eslint-plugin";
3709
- var version = "1.9.0";
3709
+ var version = "1.10.0";
3710
3710
 
3711
3711
  // src/configs/alexPluginBase.ts
3712
3712
  function createAlexPluginBaseConfig(plugin2) {
@@ -3717,7 +3717,8 @@ function createAlexPluginBaseConfig(plugin2) {
3717
3717
  },
3718
3718
  rules: {
3719
3719
  "@alextheman/no-namespace-imports": "error",
3720
- "@alextheman/no-relative-imports": "error"
3720
+ "@alextheman/no-relative-imports": "error",
3721
+ "@alextheman/use-object-shorthand": "error"
3721
3722
  }
3722
3723
  }
3723
3724
  ];
@@ -4072,11 +4073,50 @@ var noRelativeImports = create_rule_default({
4072
4073
  });
4073
4074
  var no_relative_imports_default = noRelativeImports;
4074
4075
 
4076
+ // src/rules/use-object-shorthand.ts
4077
+ var import_utils2 = require("@typescript-eslint/utils");
4078
+ var useObjectShorthand = create_rule_default({
4079
+ name: "use-object-shorthand",
4080
+ meta: {
4081
+ docs: {
4082
+ description: 'Encourage the use of object shorthand (e.g. const property = "Hello"; const object = { property });'
4083
+ },
4084
+ messages: {
4085
+ useShorthand: "{ {{source}} } is not allowed. Please use the object shorthand."
4086
+ },
4087
+ type: "suggestion",
4088
+ fixable: "code",
4089
+ schema: []
4090
+ },
4091
+ defaultOptions: [],
4092
+ create(context) {
4093
+ return {
4094
+ Property(node) {
4095
+ if (node.key.type === import_utils2.AST_NODE_TYPES.Identifier && node.value.type === import_utils2.AST_NODE_TYPES.Identifier && node.key.name === node.value.name && !node.shorthand) {
4096
+ context.report({
4097
+ node,
4098
+ messageId: "useShorthand",
4099
+ data: {
4100
+ source: context.sourceCode.getText(node)
4101
+ },
4102
+ fix(fixer) {
4103
+ const key = node.key;
4104
+ return fixer.replaceTextRange([node.range[0], node.range[1]], key.name);
4105
+ }
4106
+ });
4107
+ }
4108
+ }
4109
+ };
4110
+ }
4111
+ });
4112
+ var use_object_shorthand_default = useObjectShorthand;
4113
+
4075
4114
  // src/rules/index.ts
4076
4115
  var rules_default = {
4077
4116
  "no-namespace-imports": no_namespace_imports_default,
4078
4117
  "no-relative-imports": no_relative_imports_default,
4079
- "no-plugin-configs-access-from-src-configs": no_plugin_configs_access_from_src_configs_default
4118
+ "no-plugin-configs-access-from-src-configs": no_plugin_configs_access_from_src_configs_default,
4119
+ "use-object-shorthand": use_object_shorthand_default
4080
4120
  };
4081
4121
 
4082
4122
  // src/index.ts
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@ import { Linter } from 'eslint';
2
2
  import { Config } from 'prettier';
3
3
 
4
4
  var name = "@alextheman/eslint-plugin";
5
- var version = "1.9.0";
5
+ var version = "1.10.0";
6
6
 
7
7
  declare const prettierRules: Config;
8
8
 
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Linter } from 'eslint';
2
2
  import { Config } from 'prettier';
3
3
 
4
4
  var name = "@alextheman/eslint-plugin";
5
- var version = "1.9.0";
5
+ var version = "1.10.0";
6
6
 
7
7
  declare const prettierRules: Config;
8
8
 
package/dist/index.js CHANGED
@@ -3692,7 +3692,7 @@ var require_globals2 = __commonJS({
3692
3692
 
3693
3693
  // package.json
3694
3694
  var name = "@alextheman/eslint-plugin";
3695
- var version = "1.9.0";
3695
+ var version = "1.10.0";
3696
3696
 
3697
3697
  // src/configs/alexPluginBase.ts
3698
3698
  function createAlexPluginBaseConfig(plugin2) {
@@ -3703,7 +3703,8 @@ function createAlexPluginBaseConfig(plugin2) {
3703
3703
  },
3704
3704
  rules: {
3705
3705
  "@alextheman/no-namespace-imports": "error",
3706
- "@alextheman/no-relative-imports": "error"
3706
+ "@alextheman/no-relative-imports": "error",
3707
+ "@alextheman/use-object-shorthand": "error"
3707
3708
  }
3708
3709
  }
3709
3710
  ];
@@ -4058,11 +4059,50 @@ var noRelativeImports = create_rule_default({
4058
4059
  });
4059
4060
  var no_relative_imports_default = noRelativeImports;
4060
4061
 
4062
+ // src/rules/use-object-shorthand.ts
4063
+ import { AST_NODE_TYPES } from "@typescript-eslint/utils";
4064
+ var useObjectShorthand = create_rule_default({
4065
+ name: "use-object-shorthand",
4066
+ meta: {
4067
+ docs: {
4068
+ description: 'Encourage the use of object shorthand (e.g. const property = "Hello"; const object = { property });'
4069
+ },
4070
+ messages: {
4071
+ useShorthand: "{ {{source}} } is not allowed. Please use the object shorthand."
4072
+ },
4073
+ type: "suggestion",
4074
+ fixable: "code",
4075
+ schema: []
4076
+ },
4077
+ defaultOptions: [],
4078
+ create(context) {
4079
+ return {
4080
+ Property(node) {
4081
+ if (node.key.type === AST_NODE_TYPES.Identifier && node.value.type === AST_NODE_TYPES.Identifier && node.key.name === node.value.name && !node.shorthand) {
4082
+ context.report({
4083
+ node,
4084
+ messageId: "useShorthand",
4085
+ data: {
4086
+ source: context.sourceCode.getText(node)
4087
+ },
4088
+ fix(fixer) {
4089
+ const key = node.key;
4090
+ return fixer.replaceTextRange([node.range[0], node.range[1]], key.name);
4091
+ }
4092
+ });
4093
+ }
4094
+ }
4095
+ };
4096
+ }
4097
+ });
4098
+ var use_object_shorthand_default = useObjectShorthand;
4099
+
4061
4100
  // src/rules/index.ts
4062
4101
  var rules_default = {
4063
4102
  "no-namespace-imports": no_namespace_imports_default,
4064
4103
  "no-relative-imports": no_relative_imports_default,
4065
- "no-plugin-configs-access-from-src-configs": no_plugin_configs_access_from_src_configs_default
4104
+ "no-plugin-configs-access-from-src-configs": no_plugin_configs_access_from_src_configs_default,
4105
+ "use-object-shorthand": use_object_shorthand_default
4066
4106
  };
4067
4107
 
4068
4108
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/eslint-plugin",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",