@alextheman/eslint-plugin 1.13.1 → 1.13.3

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.13.1";
3709
+ var version = "1.13.3";
3710
3710
 
3711
3711
  // src/configs/alexPluginBase.ts
3712
3712
  function createAlexPluginBaseConfig(plugin) {
@@ -3896,8 +3896,8 @@ var typeScriptReactBase = [
3896
3896
  {
3897
3897
  paths: [
3898
3898
  {
3899
- name: "@mui/material",
3900
- message: 'Please use `import Component from "@mui/material/Component"` instead. See https://mui.com/material-ui/guides/minimizing-bundle-size/ for more information.'
3899
+ regex: "^@mui/[^/]+$",
3900
+ message: 'Please use `import Component from "@mui/[package]/Component"` instead. See https://mui.com/material-ui/guides/minimizing-bundle-size/ for more information.'
3901
3901
  }
3902
3902
  ]
3903
3903
  }
@@ -4201,7 +4201,9 @@ var noRelativeImports = createRule_default({
4201
4201
  meta: {
4202
4202
  docs: { description: "Forbid the use of relative imports" },
4203
4203
  messages: {
4204
- message: 'Relative import from "{{source}}" is not allowed.',
4204
+ strictNoRelative: 'Relative import from "{{source}}" is not allowed.',
4205
+ rootOnly: 'Relative import from "{{source}}" is not allowed to leave the current folder.',
4206
+ exceededAllowedDepth: 'Relative import from "{{source}}" is not allowed. Relative imports must be no more than {{depth}} level{{s}} deep.',
4205
4207
  stupidPath: "For the love of God, please do not mix relative path parts in your import statements like that! How can you possibly be ok with {{source}}?!"
4206
4208
  },
4207
4209
  type: "suggestion",
@@ -4220,22 +4222,22 @@ var noRelativeImports = createRule_default({
4220
4222
  defaultOptions: [{ depth: void 0 }],
4221
4223
  create(context) {
4222
4224
  var _a;
4223
- const depth = (_a = context.options[0]) == null ? void 0 : _a.depth;
4224
- if (depth !== void 0) {
4225
- if (depth % 1 !== 0) {
4225
+ const allowedDepth = (_a = context.options[0]) == null ? void 0 : _a.depth;
4226
+ if (allowedDepth !== void 0) {
4227
+ if (allowedDepth % 1 !== 0) {
4226
4228
  throw new Error("NON_INTEGER_DEPTH_NOT_ALLOWED");
4227
4229
  }
4228
- if (depth < 0) {
4230
+ if (allowedDepth < 0) {
4229
4231
  throw new Error("NEGATIVE_DEPTH_NOT_ALLOWED");
4230
4232
  }
4231
4233
  }
4232
4234
  return {
4233
4235
  ImportDeclaration(node) {
4234
4236
  if (node.source.value.includes("./") || node.source.value.includes("../")) {
4235
- if (depth === void 0) {
4237
+ if (allowedDepth === void 0) {
4236
4238
  return context.report({
4237
4239
  node,
4238
- messageId: "message",
4240
+ messageId: "strictNoRelative",
4239
4241
  data: {
4240
4242
  source: node.source.value
4241
4243
  }
@@ -4260,22 +4262,33 @@ var noRelativeImports = createRule_default({
4260
4262
  }
4261
4263
  });
4262
4264
  }
4263
- if (depth === 0 && importPathParts[0] === ".") {
4265
+ if (allowedDepth === 0 && importPathParts[0] === ".") {
4264
4266
  return;
4265
4267
  }
4266
4268
  let endOfRelativePathFound = false;
4267
- for (const part of importPathParts.slice(0, depth + 1)) {
4269
+ for (const part of importPathParts.slice(0, allowedDepth + 1)) {
4268
4270
  if (part !== "..") {
4269
4271
  endOfRelativePathFound = true;
4270
4272
  break;
4271
4273
  }
4272
4274
  }
4273
4275
  if (!endOfRelativePathFound) {
4276
+ if (allowedDepth === 0) {
4277
+ return context.report({
4278
+ node,
4279
+ messageId: "rootOnly",
4280
+ data: {
4281
+ source: node.source.value
4282
+ }
4283
+ });
4284
+ }
4274
4285
  return context.report({
4275
4286
  node,
4276
- messageId: "message",
4287
+ messageId: "exceededAllowedDepth",
4277
4288
  data: {
4278
- source: node.source.value
4289
+ source: node.source.value,
4290
+ depth: allowedDepth,
4291
+ s: allowedDepth !== 1 ? "s" : ""
4279
4292
  }
4280
4293
  });
4281
4294
  }
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ import z from 'zod';
3
3
  import { Config } from 'prettier';
4
4
 
5
5
  var name = "@alextheman/eslint-plugin";
6
- var version = "1.13.1";
6
+ var version = "1.13.3";
7
7
 
8
8
  interface AlexPlugin {
9
9
  meta: {
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import z from 'zod';
3
3
  import { Config } from 'prettier';
4
4
 
5
5
  var name = "@alextheman/eslint-plugin";
6
- var version = "1.13.1";
6
+ var version = "1.13.3";
7
7
 
8
8
  interface AlexPlugin {
9
9
  meta: {
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.13.1";
3695
+ var version = "1.13.3";
3696
3696
 
3697
3697
  // src/configs/alexPluginBase.ts
3698
3698
  function createAlexPluginBaseConfig(plugin) {
@@ -3882,8 +3882,8 @@ var typeScriptReactBase = [
3882
3882
  {
3883
3883
  paths: [
3884
3884
  {
3885
- name: "@mui/material",
3886
- message: 'Please use `import Component from "@mui/material/Component"` instead. See https://mui.com/material-ui/guides/minimizing-bundle-size/ for more information.'
3885
+ regex: "^@mui/[^/]+$",
3886
+ message: 'Please use `import Component from "@mui/[package]/Component"` instead. See https://mui.com/material-ui/guides/minimizing-bundle-size/ for more information.'
3887
3887
  }
3888
3888
  ]
3889
3889
  }
@@ -4187,7 +4187,9 @@ var noRelativeImports = createRule_default({
4187
4187
  meta: {
4188
4188
  docs: { description: "Forbid the use of relative imports" },
4189
4189
  messages: {
4190
- message: 'Relative import from "{{source}}" is not allowed.',
4190
+ strictNoRelative: 'Relative import from "{{source}}" is not allowed.',
4191
+ rootOnly: 'Relative import from "{{source}}" is not allowed to leave the current folder.',
4192
+ exceededAllowedDepth: 'Relative import from "{{source}}" is not allowed. Relative imports must be no more than {{depth}} level{{s}} deep.',
4191
4193
  stupidPath: "For the love of God, please do not mix relative path parts in your import statements like that! How can you possibly be ok with {{source}}?!"
4192
4194
  },
4193
4195
  type: "suggestion",
@@ -4206,22 +4208,22 @@ var noRelativeImports = createRule_default({
4206
4208
  defaultOptions: [{ depth: void 0 }],
4207
4209
  create(context) {
4208
4210
  var _a;
4209
- const depth = (_a = context.options[0]) == null ? void 0 : _a.depth;
4210
- if (depth !== void 0) {
4211
- if (depth % 1 !== 0) {
4211
+ const allowedDepth = (_a = context.options[0]) == null ? void 0 : _a.depth;
4212
+ if (allowedDepth !== void 0) {
4213
+ if (allowedDepth % 1 !== 0) {
4212
4214
  throw new Error("NON_INTEGER_DEPTH_NOT_ALLOWED");
4213
4215
  }
4214
- if (depth < 0) {
4216
+ if (allowedDepth < 0) {
4215
4217
  throw new Error("NEGATIVE_DEPTH_NOT_ALLOWED");
4216
4218
  }
4217
4219
  }
4218
4220
  return {
4219
4221
  ImportDeclaration(node) {
4220
4222
  if (node.source.value.includes("./") || node.source.value.includes("../")) {
4221
- if (depth === void 0) {
4223
+ if (allowedDepth === void 0) {
4222
4224
  return context.report({
4223
4225
  node,
4224
- messageId: "message",
4226
+ messageId: "strictNoRelative",
4225
4227
  data: {
4226
4228
  source: node.source.value
4227
4229
  }
@@ -4246,22 +4248,33 @@ var noRelativeImports = createRule_default({
4246
4248
  }
4247
4249
  });
4248
4250
  }
4249
- if (depth === 0 && importPathParts[0] === ".") {
4251
+ if (allowedDepth === 0 && importPathParts[0] === ".") {
4250
4252
  return;
4251
4253
  }
4252
4254
  let endOfRelativePathFound = false;
4253
- for (const part of importPathParts.slice(0, depth + 1)) {
4255
+ for (const part of importPathParts.slice(0, allowedDepth + 1)) {
4254
4256
  if (part !== "..") {
4255
4257
  endOfRelativePathFound = true;
4256
4258
  break;
4257
4259
  }
4258
4260
  }
4259
4261
  if (!endOfRelativePathFound) {
4262
+ if (allowedDepth === 0) {
4263
+ return context.report({
4264
+ node,
4265
+ messageId: "rootOnly",
4266
+ data: {
4267
+ source: node.source.value
4268
+ }
4269
+ });
4270
+ }
4260
4271
  return context.report({
4261
4272
  node,
4262
- messageId: "message",
4273
+ messageId: "exceededAllowedDepth",
4263
4274
  data: {
4264
- source: node.source.value
4275
+ source: node.source.value,
4276
+ depth: allowedDepth,
4277
+ s: allowedDepth !== 1 ? "s" : ""
4265
4278
  }
4266
4279
  });
4267
4280
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/eslint-plugin",
3
- "version": "1.13.1",
3
+ "version": "1.13.3",
4
4
  "description": "A package to provide custom ESLint rules and configs",
5
5
  "license": "ISC",
6
6
  "author": "alextheman",