@alextheman/eslint-plugin 4.3.0 → 4.4.1
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 +140 -96
- package/dist/index.d.cts +71 -1
- package/dist/index.d.ts +71 -1
- package/dist/index.js +139 -96
- package/package.json +35 -36
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
30
30
|
let __alextheman_utility = require("@alextheman/utility");
|
|
31
|
+
let __typescript_eslint_utils = require("@typescript-eslint/utils");
|
|
32
|
+
let zod = require("zod");
|
|
33
|
+
zod = __toESM(zod);
|
|
31
34
|
let __eslint_js = require("@eslint/js");
|
|
32
35
|
__eslint_js = __toESM(__eslint_js);
|
|
33
36
|
let eslint_config_prettier = require("eslint-config-prettier");
|
|
@@ -53,13 +56,10 @@ let eslint_plugin_react_hooks = require("eslint-plugin-react-hooks");
|
|
|
53
56
|
eslint_plugin_react_hooks = __toESM(eslint_plugin_react_hooks);
|
|
54
57
|
let eslint_plugin_package_json = require("eslint-plugin-package-json");
|
|
55
58
|
eslint_plugin_package_json = __toESM(eslint_plugin_package_json);
|
|
56
|
-
let __typescript_eslint_utils = require("@typescript-eslint/utils");
|
|
57
|
-
let zod = require("zod");
|
|
58
|
-
zod = __toESM(zod);
|
|
59
59
|
|
|
60
60
|
//#region package.json
|
|
61
61
|
var name = "@alextheman/eslint-plugin";
|
|
62
|
-
var version = "4.
|
|
62
|
+
var version = "4.4.1";
|
|
63
63
|
|
|
64
64
|
//#endregion
|
|
65
65
|
//#region node_modules/.pnpm/globals@16.5.0/node_modules/globals/globals.json
|
|
@@ -3416,8 +3416,68 @@ var require_globals = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3416
3416
|
}));
|
|
3417
3417
|
|
|
3418
3418
|
//#endregion
|
|
3419
|
-
//#region src/configs/
|
|
3419
|
+
//#region src/configs/helpers/restrictedImports/generalRestrictedImports.ts
|
|
3420
3420
|
var import_globals$2 = /* @__PURE__ */ __toESM(require_globals(), 1);
|
|
3421
|
+
const generalRestrictedImports = { patterns: [{
|
|
3422
|
+
group: ["node_modules"],
|
|
3423
|
+
message: "Do not import directly from node_modules."
|
|
3424
|
+
}] };
|
|
3425
|
+
var generalRestrictedImports_default = generalRestrictedImports;
|
|
3426
|
+
|
|
3427
|
+
//#endregion
|
|
3428
|
+
//#region src/utility/checkCallExpression.ts
|
|
3429
|
+
function checkCallExpression(node, objectName, propertyName) {
|
|
3430
|
+
return node.callee.type === __typescript_eslint_utils.AST_NODE_TYPES.MemberExpression && node.callee.object.type === __typescript_eslint_utils.AST_NODE_TYPES.Identifier && node.callee.object.name === objectName && node.callee.property.type === __typescript_eslint_utils.AST_NODE_TYPES.Identifier && node.callee.property.name === propertyName;
|
|
3431
|
+
}
|
|
3432
|
+
var checkCallExpression_default = checkCallExpression;
|
|
3433
|
+
|
|
3434
|
+
//#endregion
|
|
3435
|
+
//#region src/utility/combineRestrictedImports.ts
|
|
3436
|
+
function combineRestrictedImports(...groups) {
|
|
3437
|
+
const paths = [];
|
|
3438
|
+
const patterns = [];
|
|
3439
|
+
for (const group of groups) {
|
|
3440
|
+
if (group.paths) paths.push(...group.paths);
|
|
3441
|
+
if (group.patterns) patterns.push(...group.patterns);
|
|
3442
|
+
}
|
|
3443
|
+
const combinedGroup = {
|
|
3444
|
+
paths,
|
|
3445
|
+
patterns
|
|
3446
|
+
};
|
|
3447
|
+
if (combinedGroup.paths.length === 0) return (0, __alextheman_utility.omitProperties)(combinedGroup, "paths");
|
|
3448
|
+
if (combinedGroup.patterns.length === 0) return (0, __alextheman_utility.omitProperties)(combinedGroup, "patterns");
|
|
3449
|
+
return combinedGroup;
|
|
3450
|
+
}
|
|
3451
|
+
var combineRestrictedImports_default = combineRestrictedImports;
|
|
3452
|
+
|
|
3453
|
+
//#endregion
|
|
3454
|
+
//#region src/utility/createRuleSchemaFromZodSchema.ts
|
|
3455
|
+
function createRuleSchemaFromZodSchema(schema$1) {
|
|
3456
|
+
return [(0, __alextheman_utility.omitProperties)(zod.default.toJSONSchema(schema$1), "$schema")];
|
|
3457
|
+
}
|
|
3458
|
+
var createRuleSchemaFromZodSchema_default = createRuleSchemaFromZodSchema;
|
|
3459
|
+
|
|
3460
|
+
//#endregion
|
|
3461
|
+
//#region src/utility/getImportSpecifiersAfterRemoving.ts
|
|
3462
|
+
function getImportSpecifiersAfterRemoving(context, specifiers, importToRemove) {
|
|
3463
|
+
return specifiers.filter((specifier) => {
|
|
3464
|
+
return !(specifier.imported.name === importToRemove);
|
|
3465
|
+
}).map((specifier) => {
|
|
3466
|
+
return context.sourceCode.getText(specifier);
|
|
3467
|
+
}).join(", ");
|
|
3468
|
+
}
|
|
3469
|
+
var getImportSpecifiersAfterRemoving_default = getImportSpecifiersAfterRemoving;
|
|
3470
|
+
|
|
3471
|
+
//#endregion
|
|
3472
|
+
//#region src/configs/helpers/restrictedImports/testsRestrictedImports.ts
|
|
3473
|
+
const testsRestrictedImports = combineRestrictedImports_default(generalRestrictedImports_default, { paths: [{
|
|
3474
|
+
message: "Use test functions from vitest instead.",
|
|
3475
|
+
name: "node:test"
|
|
3476
|
+
}] });
|
|
3477
|
+
var testsRestrictedImports_default = testsRestrictedImports;
|
|
3478
|
+
|
|
3479
|
+
//#endregion
|
|
3480
|
+
//#region src/configs/personal/testsBase.ts
|
|
3421
3481
|
const personalTestsBaseConfig = [{
|
|
3422
3482
|
files: ["**/*.test.{js,ts}"],
|
|
3423
3483
|
languageOptions: { globals: {
|
|
@@ -3442,10 +3502,7 @@ const personalTestsBaseConfig = [{
|
|
|
3442
3502
|
name: "expect"
|
|
3443
3503
|
}
|
|
3444
3504
|
],
|
|
3445
|
-
"no-restricted-imports": ["error",
|
|
3446
|
-
message: "Use test functions from vitest instead.",
|
|
3447
|
-
name: "node:test"
|
|
3448
|
-
}] }]
|
|
3505
|
+
"no-restricted-imports": ["error", testsRestrictedImports_default]
|
|
3449
3506
|
}
|
|
3450
3507
|
}];
|
|
3451
3508
|
var testsBase_default$1 = personalTestsBaseConfig;
|
|
@@ -3540,10 +3597,7 @@ const javaScriptBase = [
|
|
|
3540
3597
|
"no-lonely-if": "error",
|
|
3541
3598
|
"no-new-wrappers": "error",
|
|
3542
3599
|
"no-param-reassign": "error",
|
|
3543
|
-
"no-restricted-imports": ["error",
|
|
3544
|
-
group: ["node_modules"],
|
|
3545
|
-
message: "What on Earth are you doing? Leave poor node_modules alone!"
|
|
3546
|
-
}] }],
|
|
3600
|
+
"no-restricted-imports": ["error", generalRestrictedImports_default],
|
|
3547
3601
|
"no-undef": "error",
|
|
3548
3602
|
"no-unused-vars": ["error", unusedVarsIgnorePatterns_default],
|
|
3549
3603
|
"no-useless-rename": "error",
|
|
@@ -3760,6 +3814,14 @@ const reactBase = [
|
|
|
3760
3814
|
];
|
|
3761
3815
|
var reactBase_default$1 = reactBase;
|
|
3762
3816
|
|
|
3817
|
+
//#endregion
|
|
3818
|
+
//#region src/configs/helpers/restrictedImports/reactRestrictedImports.ts
|
|
3819
|
+
const reactRestrictedImports = combineRestrictedImports_default(generalRestrictedImports_default, { patterns: [{
|
|
3820
|
+
message: "Please use `import Component from \"@mui/[package]/Component\"` instead. See https://mui.com/material-ui/guides/minimizing-bundle-size/ for more information.",
|
|
3821
|
+
regex: "^@mui/[^/]+$"
|
|
3822
|
+
}] });
|
|
3823
|
+
var reactRestrictedImports_default = reactRestrictedImports;
|
|
3824
|
+
|
|
3763
3825
|
//#endregion
|
|
3764
3826
|
//#region src/configs/personal/reactBase.ts
|
|
3765
3827
|
const personalReactBaseConfig = [{
|
|
@@ -3771,10 +3833,7 @@ const personalReactBaseConfig = [{
|
|
|
3771
3833
|
"react-refresh": eslint_plugin_react_refresh.default
|
|
3772
3834
|
},
|
|
3773
3835
|
rules: {
|
|
3774
|
-
"no-restricted-imports": ["error",
|
|
3775
|
-
message: "Please use `import Component from \"@mui/[package]/Component\"` instead. See https://mui.com/material-ui/guides/minimizing-bundle-size/ for more information.",
|
|
3776
|
-
regex: "^@mui/[^/]+$"
|
|
3777
|
-
}] }],
|
|
3836
|
+
"no-restricted-imports": ["error", reactRestrictedImports_default],
|
|
3778
3837
|
"react-hooks/exhaustive-deps": "off",
|
|
3779
3838
|
"react-hooks/refs": "off",
|
|
3780
3839
|
"react-refresh/only-export-components": "off",
|
|
@@ -3828,6 +3887,25 @@ const typeScriptBase = [
|
|
|
3828
3887
|
];
|
|
3829
3888
|
var typeScriptBase_default$1 = typeScriptBase;
|
|
3830
3889
|
|
|
3890
|
+
//#endregion
|
|
3891
|
+
//#region src/configs/helpers/restrictedImports/eslintPluginRestrictedImports.ts
|
|
3892
|
+
const eslintPluginRestrictedImports = combineRestrictedImports_default(generalRestrictedImports_default, { paths: [...[
|
|
3893
|
+
"src/alexPlugin",
|
|
3894
|
+
"src/index",
|
|
3895
|
+
"src"
|
|
3896
|
+
].map((name$1) => {
|
|
3897
|
+
return {
|
|
3898
|
+
importNames: ["default"],
|
|
3899
|
+
message: "Do not import the plugin directly from the config files. Please create a function that takes in the plugin and returns the config instead.",
|
|
3900
|
+
name: name$1
|
|
3901
|
+
};
|
|
3902
|
+
}), {
|
|
3903
|
+
importNames: ["default"],
|
|
3904
|
+
message: "Please import from \"src/configs/helpers/eslint-plugin-react-hooks\" instead.",
|
|
3905
|
+
name: "eslint-plugin-react-hooks"
|
|
3906
|
+
}] });
|
|
3907
|
+
var eslintPluginRestrictedImports_default = eslintPluginRestrictedImports;
|
|
3908
|
+
|
|
3831
3909
|
//#endregion
|
|
3832
3910
|
//#region src/configs/personal/eslintPlugin.ts
|
|
3833
3911
|
function createPersonalEslintPluginConfig(plugin) {
|
|
@@ -3839,21 +3917,7 @@ function createPersonalEslintPluginConfig(plugin) {
|
|
|
3839
3917
|
},
|
|
3840
3918
|
rules: {
|
|
3841
3919
|
"@alextheman/no-plugin-configs-access-from-src-configs": "error",
|
|
3842
|
-
"no-restricted-imports": ["error",
|
|
3843
|
-
"src/alexPlugin",
|
|
3844
|
-
"src/index",
|
|
3845
|
-
"src"
|
|
3846
|
-
].map((name$1) => {
|
|
3847
|
-
return {
|
|
3848
|
-
importNames: ["default"],
|
|
3849
|
-
message: "Do not import the plugin directly from the config files. Please create a function that takes in the plugin and returns the config instead.",
|
|
3850
|
-
name: name$1
|
|
3851
|
-
};
|
|
3852
|
-
}), {
|
|
3853
|
-
importNames: ["default"],
|
|
3854
|
-
message: "Please import from \"src/configs/helpers/eslint-plugin-react-hooks\" instead so you don't have to deal with eslint-plugin-react-hooks' ridiculous plugin typing.",
|
|
3855
|
-
name: "eslint-plugin-react-hooks"
|
|
3856
|
-
}] }]
|
|
3920
|
+
"no-restricted-imports": ["error", eslintPluginRestrictedImports_default]
|
|
3857
3921
|
}
|
|
3858
3922
|
}, {
|
|
3859
3923
|
files: ["src/rules/index.ts", "src/configs/**"],
|
|
@@ -3862,27 +3926,32 @@ function createPersonalEslintPluginConfig(plugin) {
|
|
|
3862
3926
|
}
|
|
3863
3927
|
var eslintPlugin_default = createPersonalEslintPluginConfig;
|
|
3864
3928
|
|
|
3929
|
+
//#endregion
|
|
3930
|
+
//#region src/configs/helpers/restrictedImports/neurosongsBackEndRestrictedImports.ts
|
|
3931
|
+
const neurosongsBackEndRestrictedImports = combineRestrictedImports_default(generalRestrictedImports_default, { paths: [
|
|
3932
|
+
{
|
|
3933
|
+
importNames: ["setPrismaClient"],
|
|
3934
|
+
message: "Do not attempt to reset the Prisma Client outside setup files.",
|
|
3935
|
+
name: "src/database/client"
|
|
3936
|
+
},
|
|
3937
|
+
{
|
|
3938
|
+
message: "Do not use the generated Prisma types. Use the types exported from @neurosongs/types instead.",
|
|
3939
|
+
name: "@neurosongs/prisma-client/types"
|
|
3940
|
+
},
|
|
3941
|
+
{
|
|
3942
|
+
importNames: ["PrismaClient"],
|
|
3943
|
+
message: "Please use the PrismaClient from @neurosongs/types instead.",
|
|
3944
|
+
name: "@neurosongs/prisma-client/prisma"
|
|
3945
|
+
}
|
|
3946
|
+
] });
|
|
3947
|
+
var neurosongsBackEndRestrictedImports_default = neurosongsBackEndRestrictedImports;
|
|
3948
|
+
|
|
3865
3949
|
//#endregion
|
|
3866
3950
|
//#region src/configs/personal/neurosongsBackEnd.ts
|
|
3867
3951
|
const neurosongsBackEndConfig = [
|
|
3868
3952
|
{
|
|
3869
3953
|
name: "@alextheman/personal/neurosongs-back-end",
|
|
3870
|
-
rules: { "no-restricted-imports": ["error",
|
|
3871
|
-
{
|
|
3872
|
-
importNames: ["setPrismaClient"],
|
|
3873
|
-
message: "Do not attempt to reset the Prisma Client outside setup files.",
|
|
3874
|
-
name: "src/database/client"
|
|
3875
|
-
},
|
|
3876
|
-
{
|
|
3877
|
-
message: "Do not use the generated Prisma types. Use the types exported from @neurosongs/types instead.",
|
|
3878
|
-
name: "@neurosongs/prisma-client/types"
|
|
3879
|
-
},
|
|
3880
|
-
{
|
|
3881
|
-
importNames: ["PrismaClient"],
|
|
3882
|
-
message: "Please use the PrismaClient from @neurosongs/types instead.",
|
|
3883
|
-
name: "@neurosongs/prisma-client/prisma"
|
|
3884
|
-
}
|
|
3885
|
-
] }] }
|
|
3954
|
+
rules: { "no-restricted-imports": ["error", neurosongsBackEndRestrictedImports_default] }
|
|
3886
3955
|
},
|
|
3887
3956
|
{
|
|
3888
3957
|
files: ["src/database/**/*.ts", "tests/test-utilities/setup.ts"],
|
|
@@ -3899,33 +3968,32 @@ const neurosongsBackEndConfig = [
|
|
|
3899
3968
|
];
|
|
3900
3969
|
var neurosongsBackEnd_default = neurosongsBackEndConfig;
|
|
3901
3970
|
|
|
3971
|
+
//#endregion
|
|
3972
|
+
//#region src/configs/helpers/restrictedImports/neurosongsFrontEndRestrictedImports.ts
|
|
3973
|
+
const neurosongsFrontEndRestrictedImports = combineRestrictedImports_default(reactRestrictedImports_default, {
|
|
3974
|
+
paths: [{
|
|
3975
|
+
importNames: ["PrismaClient"],
|
|
3976
|
+
message: "Do not use the Prisma Client directly in the front-end. Query an endpoint from the back-end instead.",
|
|
3977
|
+
name: "@neurosongs/types"
|
|
3978
|
+
}, ...["LoaderProvider", "Loader"].map((importName) => {
|
|
3979
|
+
return {
|
|
3980
|
+
importNames: [importName],
|
|
3981
|
+
message: `Use the internal ${importName} from src/components/${importName} instead.`,
|
|
3982
|
+
name: "@alextheman/components"
|
|
3983
|
+
};
|
|
3984
|
+
})],
|
|
3985
|
+
patterns: [{
|
|
3986
|
+
group: ["@neurosongs/prisma-client"],
|
|
3987
|
+
message: "Do not use the Prisma Client directly in the front-end. Query an endpoint from the back-end instead."
|
|
3988
|
+
}]
|
|
3989
|
+
});
|
|
3990
|
+
var neurosongsFrontEndRestrictedImports_default = neurosongsFrontEndRestrictedImports;
|
|
3991
|
+
|
|
3902
3992
|
//#endregion
|
|
3903
3993
|
//#region src/configs/personal/neurosongsFrontEnd.ts
|
|
3904
3994
|
const neurosongsFrontEndConfig = [{
|
|
3905
3995
|
name: "@alextheman/personal/neurosongs-front-end",
|
|
3906
|
-
rules: { "no-restricted-imports": ["error",
|
|
3907
|
-
paths: [
|
|
3908
|
-
{
|
|
3909
|
-
importNames: ["PrismaClient"],
|
|
3910
|
-
message: "Do not use the Prisma Client directly in the front-end. Query an endpoint from the back-end instead.",
|
|
3911
|
-
name: "@neurosongs/types"
|
|
3912
|
-
},
|
|
3913
|
-
{
|
|
3914
|
-
importNames: ["LoaderProvider"],
|
|
3915
|
-
message: "Use the internal LoaderProvider from src/components/LoaderProvider instead.",
|
|
3916
|
-
name: "@alextheman/components"
|
|
3917
|
-
},
|
|
3918
|
-
{
|
|
3919
|
-
importNames: ["Loader"],
|
|
3920
|
-
message: "Use the internal Loader from src/components/Loader instead.",
|
|
3921
|
-
name: "@alextheman/components"
|
|
3922
|
-
}
|
|
3923
|
-
],
|
|
3924
|
-
patterns: [{
|
|
3925
|
-
group: ["@neurosongs/prisma-client"],
|
|
3926
|
-
message: "Do not use the Prisma Client directly in the front-end. Query an endpoint from the back-end instead."
|
|
3927
|
-
}]
|
|
3928
|
-
}] }
|
|
3996
|
+
rules: { "no-restricted-imports": ["error", neurosongsFrontEndRestrictedImports_default] }
|
|
3929
3997
|
}];
|
|
3930
3998
|
var neurosongsFrontEnd_default = neurosongsFrontEndConfig;
|
|
3931
3999
|
|
|
@@ -4082,24 +4150,6 @@ function fixOnCondition(fixable, fix) {
|
|
|
4082
4150
|
}
|
|
4083
4151
|
var fixOnCondition_default = fixOnCondition;
|
|
4084
4152
|
|
|
4085
|
-
//#endregion
|
|
4086
|
-
//#region src/utility/createRuleSchemaFromZodSchema.ts
|
|
4087
|
-
function createRuleSchemaFromZodSchema(schema$1) {
|
|
4088
|
-
return [(0, __alextheman_utility.omitProperties)(zod.default.toJSONSchema(schema$1), "$schema")];
|
|
4089
|
-
}
|
|
4090
|
-
var createRuleSchemaFromZodSchema_default = createRuleSchemaFromZodSchema;
|
|
4091
|
-
|
|
4092
|
-
//#endregion
|
|
4093
|
-
//#region src/utility/getImportSpecifiersAfterRemoving.ts
|
|
4094
|
-
function getImportSpecifiersAfterRemoving(context, specifiers, importToRemove) {
|
|
4095
|
-
return specifiers.filter((specifier) => {
|
|
4096
|
-
return !(specifier.imported.name === importToRemove);
|
|
4097
|
-
}).map((specifier) => {
|
|
4098
|
-
return context.sourceCode.getText(specifier);
|
|
4099
|
-
}).join(", ");
|
|
4100
|
-
}
|
|
4101
|
-
var getImportSpecifiersAfterRemoving_default = getImportSpecifiersAfterRemoving;
|
|
4102
|
-
|
|
4103
4153
|
//#endregion
|
|
4104
4154
|
//#region src/rules/consistent-test-function.ts
|
|
4105
4155
|
const validTestFunctionsSchema = zod.default.enum(["test", "it"]);
|
|
@@ -4198,13 +4248,6 @@ const consistentTestFunction = createRule_default({
|
|
|
4198
4248
|
});
|
|
4199
4249
|
var consistent_test_function_default = consistentTestFunction;
|
|
4200
4250
|
|
|
4201
|
-
//#endregion
|
|
4202
|
-
//#region src/utility/checkCallExpression.ts
|
|
4203
|
-
function checkCallExpression(node, objectName, propertyName) {
|
|
4204
|
-
return node.callee.type === __typescript_eslint_utils.AST_NODE_TYPES.MemberExpression && node.callee.object.type === __typescript_eslint_utils.AST_NODE_TYPES.Identifier && node.callee.object.name === objectName && node.callee.property.type === __typescript_eslint_utils.AST_NODE_TYPES.Identifier && node.callee.property.name === propertyName;
|
|
4205
|
-
}
|
|
4206
|
-
var checkCallExpression_default = checkCallExpression;
|
|
4207
|
-
|
|
4208
4251
|
//#endregion
|
|
4209
4252
|
//#region src/rules/no-isolated-tests.ts
|
|
4210
4253
|
const noIsolatedTests = createRule_default({
|
|
@@ -4525,6 +4568,7 @@ var src_default = alexPlugin_default;
|
|
|
4525
4568
|
|
|
4526
4569
|
//#endregion
|
|
4527
4570
|
exports.checkCallExpression = checkCallExpression_default;
|
|
4571
|
+
exports.combineRestrictedImports = combineRestrictedImports_default;
|
|
4528
4572
|
exports.createRuleSchemaFromZodSchema = createRuleSchemaFromZodSchema_default;
|
|
4529
4573
|
exports.default = src_default;
|
|
4530
4574
|
exports.fixOnCondition = fixOnCondition_default;
|
package/dist/index.d.cts
CHANGED
|
@@ -113,6 +113,73 @@ declare const unusedVarsIgnorePatterns: {
|
|
|
113
113
|
//#region src/configs/helpers/vitestConfig.d.ts
|
|
114
114
|
declare function vitestConfig(environment?: VitestEnvironment): vite0.UserConfig;
|
|
115
115
|
//#endregion
|
|
116
|
+
//#region src/configs/helpers/restrictedImports/NoRestrictedImportsOptions.d.ts
|
|
117
|
+
interface RestrictedPathImportBase {
|
|
118
|
+
message: string;
|
|
119
|
+
name: string;
|
|
120
|
+
allowTypeImports?: boolean;
|
|
121
|
+
}
|
|
122
|
+
interface RestrictedPathImportImportNames extends RestrictedPathImportBase {
|
|
123
|
+
importNames: string[];
|
|
124
|
+
allowImportNames?: never;
|
|
125
|
+
}
|
|
126
|
+
interface RestrictedPathImportAllowImportNames extends RestrictedPathImportBase {
|
|
127
|
+
allowImportNames: string[];
|
|
128
|
+
importNames?: never;
|
|
129
|
+
}
|
|
130
|
+
type RestrictedPathImport = RestrictedPathImportBase | RestrictedPathImportImportNames | RestrictedPathImportAllowImportNames;
|
|
131
|
+
interface RestrictedPatternImportBase {
|
|
132
|
+
caseSensitive?: boolean;
|
|
133
|
+
message: string;
|
|
134
|
+
allowTypeImports?: boolean;
|
|
135
|
+
}
|
|
136
|
+
interface RestrictedPatternImportGroup extends RestrictedPatternImportBase {
|
|
137
|
+
group: string[];
|
|
138
|
+
regex?: never;
|
|
139
|
+
}
|
|
140
|
+
interface RestrictedPatternImportRegex extends RestrictedPatternImportBase {
|
|
141
|
+
regex: string;
|
|
142
|
+
group?: never;
|
|
143
|
+
}
|
|
144
|
+
interface RestrictedPatternImportImportNames extends RestrictedPatternImportBase {
|
|
145
|
+
importNames: string[];
|
|
146
|
+
allowImportNames?: never;
|
|
147
|
+
importNamePattern?: never;
|
|
148
|
+
allowImportNamePattern?: never;
|
|
149
|
+
}
|
|
150
|
+
interface RestrictedPatternImportAllowImportNames extends RestrictedPatternImportBase {
|
|
151
|
+
importNames?: never;
|
|
152
|
+
allowImportNames: string[];
|
|
153
|
+
importNamePattern?: never;
|
|
154
|
+
allowImportNamePattern?: never;
|
|
155
|
+
}
|
|
156
|
+
interface RestrictedPatternImportImportNamePattern extends RestrictedPatternImportBase {
|
|
157
|
+
importNames?: never;
|
|
158
|
+
allowImportNames?: never;
|
|
159
|
+
importNamePattern: string;
|
|
160
|
+
allowImportNamePattern?: never;
|
|
161
|
+
}
|
|
162
|
+
interface RestrictedPatternImportAllowImportNamePattern extends RestrictedPatternImportBase {
|
|
163
|
+
importNames?: never;
|
|
164
|
+
allowImportNames?: never;
|
|
165
|
+
importNamePattern?: never;
|
|
166
|
+
allowImportNamePattern: string;
|
|
167
|
+
}
|
|
168
|
+
type RestrictedPatternImport = RestrictedPatternImportGroup | RestrictedPatternImportRegex | RestrictedPatternImportImportNames | RestrictedPatternImportAllowImportNames | RestrictedPatternImportImportNamePattern | RestrictedPatternImportAllowImportNamePattern;
|
|
169
|
+
interface NoRestrictedImportsOptionsPathsOnly {
|
|
170
|
+
paths: RestrictedPathImport[];
|
|
171
|
+
patterns?: never;
|
|
172
|
+
}
|
|
173
|
+
interface NoRestrictedImportsOptionsPatternsOnly {
|
|
174
|
+
paths?: never;
|
|
175
|
+
patterns: RestrictedPatternImport[];
|
|
176
|
+
}
|
|
177
|
+
interface NoRestrictedImportsOptionsPathsAndPatterns {
|
|
178
|
+
paths: RestrictedPathImport[];
|
|
179
|
+
patterns: RestrictedPatternImport[];
|
|
180
|
+
}
|
|
181
|
+
type NoRestrictedImportsOptions = NoRestrictedImportsOptionsPathsOnly | NoRestrictedImportsOptionsPatternsOnly | NoRestrictedImportsOptionsPathsAndPatterns;
|
|
182
|
+
//#endregion
|
|
116
183
|
//#region src/rules/consistent-test-function.d.ts
|
|
117
184
|
declare const validTestFunctionsSchema: z.ZodEnum<{
|
|
118
185
|
test: "test";
|
|
@@ -167,10 +234,13 @@ declare function parseUseNormalizedImportsOptions(data: unknown): {
|
|
|
167
234
|
//#region src/utility/checkCallExpression.d.ts
|
|
168
235
|
declare function checkCallExpression(node: TSESTree.CallExpression, objectName: string, propertyName: string): boolean;
|
|
169
236
|
//#endregion
|
|
237
|
+
//#region src/utility/combineRestrictedImports.d.ts
|
|
238
|
+
declare function combineRestrictedImports(...groups: NoRestrictedImportsOptions[]): NoRestrictedImportsOptions;
|
|
239
|
+
//#endregion
|
|
170
240
|
//#region src/utility/createRuleSchemaFromZodSchema.d.ts
|
|
171
241
|
declare function createRuleSchemaFromZodSchema(schema: z.ZodType): JSONSchema4[];
|
|
172
242
|
//#endregion
|
|
173
243
|
//#region src/utility/getImportSpecifiersAfterRemoving.d.ts
|
|
174
244
|
declare function getImportSpecifiersAfterRemoving(context: Readonly<RuleContext<"message", [ConsistentTestFunctionOptions]>>, specifiers: TSESTree.ImportClause[], importToRemove: string): string;
|
|
175
245
|
//#endregion
|
|
176
|
-
export { type AlexPlugin, AlexPluginConfigGroup, CombinedConfig, ConfigGroupName, ConfigKey, ConsistentTestFunctionOptions, GeneralConfig, NoNamespaceImportsOptions, NoRelativeImportsOptions, PersonalConfig, PluginConfig, RuleFixerFunction, StandardiseErrorMessagesOptions, TestFunction, UseNormalizedImportsOptions, checkCallExpression, createRuleSchemaFromZodSchema, alexPlugin as default, fixOnCondition, getImportSpecifiersAfterRemoving, parseConsistentTestFunctionOptions, parseNoNamespaceImportsOptions, parseNoRelativeImportsOptions, parseStandardiseErrorMessagesOptions, parseTestFunction, parseUseNormalizedImportsOptions, prettierRules, reactLanguageOptions, sortExports, sortImports, sortObjects, typeScriptLanguageOptions, unusedVarsIgnorePatterns, vitestConfig };
|
|
246
|
+
export { type AlexPlugin, AlexPluginConfigGroup, CombinedConfig, ConfigGroupName, ConfigKey, ConsistentTestFunctionOptions, GeneralConfig, NoNamespaceImportsOptions, NoRelativeImportsOptions, type NoRestrictedImportsOptions, PersonalConfig, PluginConfig, type RestrictedPathImport, type RestrictedPatternImport, RuleFixerFunction, StandardiseErrorMessagesOptions, TestFunction, UseNormalizedImportsOptions, checkCallExpression, combineRestrictedImports, createRuleSchemaFromZodSchema, alexPlugin as default, fixOnCondition, getImportSpecifiersAfterRemoving, parseConsistentTestFunctionOptions, parseNoNamespaceImportsOptions, parseNoRelativeImportsOptions, parseStandardiseErrorMessagesOptions, parseTestFunction, parseUseNormalizedImportsOptions, prettierRules, reactLanguageOptions, sortExports, sortImports, sortObjects, typeScriptLanguageOptions, unusedVarsIgnorePatterns, vitestConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -113,6 +113,73 @@ declare const unusedVarsIgnorePatterns: {
|
|
|
113
113
|
//#region src/configs/helpers/vitestConfig.d.ts
|
|
114
114
|
declare function vitestConfig(environment?: VitestEnvironment): vite0.UserConfig;
|
|
115
115
|
//#endregion
|
|
116
|
+
//#region src/configs/helpers/restrictedImports/NoRestrictedImportsOptions.d.ts
|
|
117
|
+
interface RestrictedPathImportBase {
|
|
118
|
+
message: string;
|
|
119
|
+
name: string;
|
|
120
|
+
allowTypeImports?: boolean;
|
|
121
|
+
}
|
|
122
|
+
interface RestrictedPathImportImportNames extends RestrictedPathImportBase {
|
|
123
|
+
importNames: string[];
|
|
124
|
+
allowImportNames?: never;
|
|
125
|
+
}
|
|
126
|
+
interface RestrictedPathImportAllowImportNames extends RestrictedPathImportBase {
|
|
127
|
+
allowImportNames: string[];
|
|
128
|
+
importNames?: never;
|
|
129
|
+
}
|
|
130
|
+
type RestrictedPathImport = RestrictedPathImportBase | RestrictedPathImportImportNames | RestrictedPathImportAllowImportNames;
|
|
131
|
+
interface RestrictedPatternImportBase {
|
|
132
|
+
caseSensitive?: boolean;
|
|
133
|
+
message: string;
|
|
134
|
+
allowTypeImports?: boolean;
|
|
135
|
+
}
|
|
136
|
+
interface RestrictedPatternImportGroup extends RestrictedPatternImportBase {
|
|
137
|
+
group: string[];
|
|
138
|
+
regex?: never;
|
|
139
|
+
}
|
|
140
|
+
interface RestrictedPatternImportRegex extends RestrictedPatternImportBase {
|
|
141
|
+
regex: string;
|
|
142
|
+
group?: never;
|
|
143
|
+
}
|
|
144
|
+
interface RestrictedPatternImportImportNames extends RestrictedPatternImportBase {
|
|
145
|
+
importNames: string[];
|
|
146
|
+
allowImportNames?: never;
|
|
147
|
+
importNamePattern?: never;
|
|
148
|
+
allowImportNamePattern?: never;
|
|
149
|
+
}
|
|
150
|
+
interface RestrictedPatternImportAllowImportNames extends RestrictedPatternImportBase {
|
|
151
|
+
importNames?: never;
|
|
152
|
+
allowImportNames: string[];
|
|
153
|
+
importNamePattern?: never;
|
|
154
|
+
allowImportNamePattern?: never;
|
|
155
|
+
}
|
|
156
|
+
interface RestrictedPatternImportImportNamePattern extends RestrictedPatternImportBase {
|
|
157
|
+
importNames?: never;
|
|
158
|
+
allowImportNames?: never;
|
|
159
|
+
importNamePattern: string;
|
|
160
|
+
allowImportNamePattern?: never;
|
|
161
|
+
}
|
|
162
|
+
interface RestrictedPatternImportAllowImportNamePattern extends RestrictedPatternImportBase {
|
|
163
|
+
importNames?: never;
|
|
164
|
+
allowImportNames?: never;
|
|
165
|
+
importNamePattern?: never;
|
|
166
|
+
allowImportNamePattern: string;
|
|
167
|
+
}
|
|
168
|
+
type RestrictedPatternImport = RestrictedPatternImportGroup | RestrictedPatternImportRegex | RestrictedPatternImportImportNames | RestrictedPatternImportAllowImportNames | RestrictedPatternImportImportNamePattern | RestrictedPatternImportAllowImportNamePattern;
|
|
169
|
+
interface NoRestrictedImportsOptionsPathsOnly {
|
|
170
|
+
paths: RestrictedPathImport[];
|
|
171
|
+
patterns?: never;
|
|
172
|
+
}
|
|
173
|
+
interface NoRestrictedImportsOptionsPatternsOnly {
|
|
174
|
+
paths?: never;
|
|
175
|
+
patterns: RestrictedPatternImport[];
|
|
176
|
+
}
|
|
177
|
+
interface NoRestrictedImportsOptionsPathsAndPatterns {
|
|
178
|
+
paths: RestrictedPathImport[];
|
|
179
|
+
patterns: RestrictedPatternImport[];
|
|
180
|
+
}
|
|
181
|
+
type NoRestrictedImportsOptions = NoRestrictedImportsOptionsPathsOnly | NoRestrictedImportsOptionsPatternsOnly | NoRestrictedImportsOptionsPathsAndPatterns;
|
|
182
|
+
//#endregion
|
|
116
183
|
//#region src/rules/consistent-test-function.d.ts
|
|
117
184
|
declare const validTestFunctionsSchema: z.ZodEnum<{
|
|
118
185
|
test: "test";
|
|
@@ -167,10 +234,13 @@ declare function parseUseNormalizedImportsOptions(data: unknown): {
|
|
|
167
234
|
//#region src/utility/checkCallExpression.d.ts
|
|
168
235
|
declare function checkCallExpression(node: TSESTree.CallExpression, objectName: string, propertyName: string): boolean;
|
|
169
236
|
//#endregion
|
|
237
|
+
//#region src/utility/combineRestrictedImports.d.ts
|
|
238
|
+
declare function combineRestrictedImports(...groups: NoRestrictedImportsOptions[]): NoRestrictedImportsOptions;
|
|
239
|
+
//#endregion
|
|
170
240
|
//#region src/utility/createRuleSchemaFromZodSchema.d.ts
|
|
171
241
|
declare function createRuleSchemaFromZodSchema(schema: z.ZodType): JSONSchema4[];
|
|
172
242
|
//#endregion
|
|
173
243
|
//#region src/utility/getImportSpecifiersAfterRemoving.d.ts
|
|
174
244
|
declare function getImportSpecifiersAfterRemoving(context: Readonly<RuleContext<"message", [ConsistentTestFunctionOptions]>>, specifiers: TSESTree.ImportClause[], importToRemove: string): string;
|
|
175
245
|
//#endregion
|
|
176
|
-
export { type AlexPlugin, AlexPluginConfigGroup, CombinedConfig, ConfigGroupName, ConfigKey, type ConsistentTestFunctionOptions, GeneralConfig, type NoNamespaceImportsOptions, type NoRelativeImportsOptions, PersonalConfig, PluginConfig, type RuleFixerFunction, type StandardiseErrorMessagesOptions, type TestFunction, type UseNormalizedImportsOptions, checkCallExpression, createRuleSchemaFromZodSchema, alexPlugin as default, fixOnCondition, getImportSpecifiersAfterRemoving, parseConsistentTestFunctionOptions, parseNoNamespaceImportsOptions, parseNoRelativeImportsOptions, parseStandardiseErrorMessagesOptions, parseTestFunction, parseUseNormalizedImportsOptions, prettierRules, reactLanguageOptions, sortExports, sortImports, sortObjects, typeScriptLanguageOptions, unusedVarsIgnorePatterns, vitestConfig };
|
|
246
|
+
export { type AlexPlugin, AlexPluginConfigGroup, CombinedConfig, ConfigGroupName, ConfigKey, type ConsistentTestFunctionOptions, GeneralConfig, type NoNamespaceImportsOptions, type NoRelativeImportsOptions, type NoRestrictedImportsOptions, PersonalConfig, PluginConfig, type RestrictedPathImport, type RestrictedPatternImport, type RuleFixerFunction, type StandardiseErrorMessagesOptions, type TestFunction, type UseNormalizedImportsOptions, checkCallExpression, combineRestrictedImports, createRuleSchemaFromZodSchema, alexPlugin as default, fixOnCondition, getImportSpecifiersAfterRemoving, parseConsistentTestFunctionOptions, parseNoNamespaceImportsOptions, parseNoRelativeImportsOptions, parseStandardiseErrorMessagesOptions, parseTestFunction, parseUseNormalizedImportsOptions, prettierRules, reactLanguageOptions, sortExports, sortImports, sortObjects, typeScriptLanguageOptions, unusedVarsIgnorePatterns, vitestConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { camelToKebab, deepCopy, deepFreeze, normalizeImportPath, omitProperties } from "@alextheman/utility";
|
|
2
|
+
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
3
|
+
import z from "zod";
|
|
2
4
|
import js from "@eslint/js";
|
|
3
5
|
import prettierConfig from "eslint-config-prettier";
|
|
4
6
|
import importPlugin from "eslint-plugin-import";
|
|
@@ -12,8 +14,6 @@ import reactPlugin from "eslint-plugin-react";
|
|
|
12
14
|
import reactRefresh from "eslint-plugin-react-refresh";
|
|
13
15
|
import reactHooksPlugin from "eslint-plugin-react-hooks";
|
|
14
16
|
import packageJson from "eslint-plugin-package-json";
|
|
15
|
-
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
16
|
-
import z from "zod";
|
|
17
17
|
|
|
18
18
|
//#region rolldown:runtime
|
|
19
19
|
var __create = Object.create;
|
|
@@ -45,7 +45,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
45
45
|
//#endregion
|
|
46
46
|
//#region package.json
|
|
47
47
|
var name = "@alextheman/eslint-plugin";
|
|
48
|
-
var version = "4.
|
|
48
|
+
var version = "4.4.1";
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region node_modules/.pnpm/globals@16.5.0/node_modules/globals/globals.json
|
|
@@ -3402,8 +3402,68 @@ var require_globals = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3402
3402
|
}));
|
|
3403
3403
|
|
|
3404
3404
|
//#endregion
|
|
3405
|
-
//#region src/configs/
|
|
3405
|
+
//#region src/configs/helpers/restrictedImports/generalRestrictedImports.ts
|
|
3406
3406
|
var import_globals$2 = /* @__PURE__ */ __toESM(require_globals(), 1);
|
|
3407
|
+
const generalRestrictedImports = { patterns: [{
|
|
3408
|
+
group: ["node_modules"],
|
|
3409
|
+
message: "Do not import directly from node_modules."
|
|
3410
|
+
}] };
|
|
3411
|
+
var generalRestrictedImports_default = generalRestrictedImports;
|
|
3412
|
+
|
|
3413
|
+
//#endregion
|
|
3414
|
+
//#region src/utility/checkCallExpression.ts
|
|
3415
|
+
function checkCallExpression(node, objectName, propertyName) {
|
|
3416
|
+
return node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && node.callee.object.name === objectName && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === propertyName;
|
|
3417
|
+
}
|
|
3418
|
+
var checkCallExpression_default = checkCallExpression;
|
|
3419
|
+
|
|
3420
|
+
//#endregion
|
|
3421
|
+
//#region src/utility/combineRestrictedImports.ts
|
|
3422
|
+
function combineRestrictedImports(...groups) {
|
|
3423
|
+
const paths = [];
|
|
3424
|
+
const patterns = [];
|
|
3425
|
+
for (const group of groups) {
|
|
3426
|
+
if (group.paths) paths.push(...group.paths);
|
|
3427
|
+
if (group.patterns) patterns.push(...group.patterns);
|
|
3428
|
+
}
|
|
3429
|
+
const combinedGroup = {
|
|
3430
|
+
paths,
|
|
3431
|
+
patterns
|
|
3432
|
+
};
|
|
3433
|
+
if (combinedGroup.paths.length === 0) return omitProperties(combinedGroup, "paths");
|
|
3434
|
+
if (combinedGroup.patterns.length === 0) return omitProperties(combinedGroup, "patterns");
|
|
3435
|
+
return combinedGroup;
|
|
3436
|
+
}
|
|
3437
|
+
var combineRestrictedImports_default = combineRestrictedImports;
|
|
3438
|
+
|
|
3439
|
+
//#endregion
|
|
3440
|
+
//#region src/utility/createRuleSchemaFromZodSchema.ts
|
|
3441
|
+
function createRuleSchemaFromZodSchema(schema$1) {
|
|
3442
|
+
return [omitProperties(z.toJSONSchema(schema$1), "$schema")];
|
|
3443
|
+
}
|
|
3444
|
+
var createRuleSchemaFromZodSchema_default = createRuleSchemaFromZodSchema;
|
|
3445
|
+
|
|
3446
|
+
//#endregion
|
|
3447
|
+
//#region src/utility/getImportSpecifiersAfterRemoving.ts
|
|
3448
|
+
function getImportSpecifiersAfterRemoving(context, specifiers, importToRemove) {
|
|
3449
|
+
return specifiers.filter((specifier) => {
|
|
3450
|
+
return !(specifier.imported.name === importToRemove);
|
|
3451
|
+
}).map((specifier) => {
|
|
3452
|
+
return context.sourceCode.getText(specifier);
|
|
3453
|
+
}).join(", ");
|
|
3454
|
+
}
|
|
3455
|
+
var getImportSpecifiersAfterRemoving_default = getImportSpecifiersAfterRemoving;
|
|
3456
|
+
|
|
3457
|
+
//#endregion
|
|
3458
|
+
//#region src/configs/helpers/restrictedImports/testsRestrictedImports.ts
|
|
3459
|
+
const testsRestrictedImports = combineRestrictedImports_default(generalRestrictedImports_default, { paths: [{
|
|
3460
|
+
message: "Use test functions from vitest instead.",
|
|
3461
|
+
name: "node:test"
|
|
3462
|
+
}] });
|
|
3463
|
+
var testsRestrictedImports_default = testsRestrictedImports;
|
|
3464
|
+
|
|
3465
|
+
//#endregion
|
|
3466
|
+
//#region src/configs/personal/testsBase.ts
|
|
3407
3467
|
const personalTestsBaseConfig = [{
|
|
3408
3468
|
files: ["**/*.test.{js,ts}"],
|
|
3409
3469
|
languageOptions: { globals: {
|
|
@@ -3428,10 +3488,7 @@ const personalTestsBaseConfig = [{
|
|
|
3428
3488
|
name: "expect"
|
|
3429
3489
|
}
|
|
3430
3490
|
],
|
|
3431
|
-
"no-restricted-imports": ["error",
|
|
3432
|
-
message: "Use test functions from vitest instead.",
|
|
3433
|
-
name: "node:test"
|
|
3434
|
-
}] }]
|
|
3491
|
+
"no-restricted-imports": ["error", testsRestrictedImports_default]
|
|
3435
3492
|
}
|
|
3436
3493
|
}];
|
|
3437
3494
|
var testsBase_default$1 = personalTestsBaseConfig;
|
|
@@ -3526,10 +3583,7 @@ const javaScriptBase = [
|
|
|
3526
3583
|
"no-lonely-if": "error",
|
|
3527
3584
|
"no-new-wrappers": "error",
|
|
3528
3585
|
"no-param-reassign": "error",
|
|
3529
|
-
"no-restricted-imports": ["error",
|
|
3530
|
-
group: ["node_modules"],
|
|
3531
|
-
message: "What on Earth are you doing? Leave poor node_modules alone!"
|
|
3532
|
-
}] }],
|
|
3586
|
+
"no-restricted-imports": ["error", generalRestrictedImports_default],
|
|
3533
3587
|
"no-undef": "error",
|
|
3534
3588
|
"no-unused-vars": ["error", unusedVarsIgnorePatterns_default],
|
|
3535
3589
|
"no-useless-rename": "error",
|
|
@@ -3746,6 +3800,14 @@ const reactBase = [
|
|
|
3746
3800
|
];
|
|
3747
3801
|
var reactBase_default$1 = reactBase;
|
|
3748
3802
|
|
|
3803
|
+
//#endregion
|
|
3804
|
+
//#region src/configs/helpers/restrictedImports/reactRestrictedImports.ts
|
|
3805
|
+
const reactRestrictedImports = combineRestrictedImports_default(generalRestrictedImports_default, { patterns: [{
|
|
3806
|
+
message: "Please use `import Component from \"@mui/[package]/Component\"` instead. See https://mui.com/material-ui/guides/minimizing-bundle-size/ for more information.",
|
|
3807
|
+
regex: "^@mui/[^/]+$"
|
|
3808
|
+
}] });
|
|
3809
|
+
var reactRestrictedImports_default = reactRestrictedImports;
|
|
3810
|
+
|
|
3749
3811
|
//#endregion
|
|
3750
3812
|
//#region src/configs/personal/reactBase.ts
|
|
3751
3813
|
const personalReactBaseConfig = [{
|
|
@@ -3757,10 +3819,7 @@ const personalReactBaseConfig = [{
|
|
|
3757
3819
|
"react-refresh": reactRefresh
|
|
3758
3820
|
},
|
|
3759
3821
|
rules: {
|
|
3760
|
-
"no-restricted-imports": ["error",
|
|
3761
|
-
message: "Please use `import Component from \"@mui/[package]/Component\"` instead. See https://mui.com/material-ui/guides/minimizing-bundle-size/ for more information.",
|
|
3762
|
-
regex: "^@mui/[^/]+$"
|
|
3763
|
-
}] }],
|
|
3822
|
+
"no-restricted-imports": ["error", reactRestrictedImports_default],
|
|
3764
3823
|
"react-hooks/exhaustive-deps": "off",
|
|
3765
3824
|
"react-hooks/refs": "off",
|
|
3766
3825
|
"react-refresh/only-export-components": "off",
|
|
@@ -3814,6 +3873,25 @@ const typeScriptBase = [
|
|
|
3814
3873
|
];
|
|
3815
3874
|
var typeScriptBase_default$1 = typeScriptBase;
|
|
3816
3875
|
|
|
3876
|
+
//#endregion
|
|
3877
|
+
//#region src/configs/helpers/restrictedImports/eslintPluginRestrictedImports.ts
|
|
3878
|
+
const eslintPluginRestrictedImports = combineRestrictedImports_default(generalRestrictedImports_default, { paths: [...[
|
|
3879
|
+
"src/alexPlugin",
|
|
3880
|
+
"src/index",
|
|
3881
|
+
"src"
|
|
3882
|
+
].map((name$1) => {
|
|
3883
|
+
return {
|
|
3884
|
+
importNames: ["default"],
|
|
3885
|
+
message: "Do not import the plugin directly from the config files. Please create a function that takes in the plugin and returns the config instead.",
|
|
3886
|
+
name: name$1
|
|
3887
|
+
};
|
|
3888
|
+
}), {
|
|
3889
|
+
importNames: ["default"],
|
|
3890
|
+
message: "Please import from \"src/configs/helpers/eslint-plugin-react-hooks\" instead.",
|
|
3891
|
+
name: "eslint-plugin-react-hooks"
|
|
3892
|
+
}] });
|
|
3893
|
+
var eslintPluginRestrictedImports_default = eslintPluginRestrictedImports;
|
|
3894
|
+
|
|
3817
3895
|
//#endregion
|
|
3818
3896
|
//#region src/configs/personal/eslintPlugin.ts
|
|
3819
3897
|
function createPersonalEslintPluginConfig(plugin) {
|
|
@@ -3825,21 +3903,7 @@ function createPersonalEslintPluginConfig(plugin) {
|
|
|
3825
3903
|
},
|
|
3826
3904
|
rules: {
|
|
3827
3905
|
"@alextheman/no-plugin-configs-access-from-src-configs": "error",
|
|
3828
|
-
"no-restricted-imports": ["error",
|
|
3829
|
-
"src/alexPlugin",
|
|
3830
|
-
"src/index",
|
|
3831
|
-
"src"
|
|
3832
|
-
].map((name$1) => {
|
|
3833
|
-
return {
|
|
3834
|
-
importNames: ["default"],
|
|
3835
|
-
message: "Do not import the plugin directly from the config files. Please create a function that takes in the plugin and returns the config instead.",
|
|
3836
|
-
name: name$1
|
|
3837
|
-
};
|
|
3838
|
-
}), {
|
|
3839
|
-
importNames: ["default"],
|
|
3840
|
-
message: "Please import from \"src/configs/helpers/eslint-plugin-react-hooks\" instead so you don't have to deal with eslint-plugin-react-hooks' ridiculous plugin typing.",
|
|
3841
|
-
name: "eslint-plugin-react-hooks"
|
|
3842
|
-
}] }]
|
|
3906
|
+
"no-restricted-imports": ["error", eslintPluginRestrictedImports_default]
|
|
3843
3907
|
}
|
|
3844
3908
|
}, {
|
|
3845
3909
|
files: ["src/rules/index.ts", "src/configs/**"],
|
|
@@ -3848,27 +3912,32 @@ function createPersonalEslintPluginConfig(plugin) {
|
|
|
3848
3912
|
}
|
|
3849
3913
|
var eslintPlugin_default = createPersonalEslintPluginConfig;
|
|
3850
3914
|
|
|
3915
|
+
//#endregion
|
|
3916
|
+
//#region src/configs/helpers/restrictedImports/neurosongsBackEndRestrictedImports.ts
|
|
3917
|
+
const neurosongsBackEndRestrictedImports = combineRestrictedImports_default(generalRestrictedImports_default, { paths: [
|
|
3918
|
+
{
|
|
3919
|
+
importNames: ["setPrismaClient"],
|
|
3920
|
+
message: "Do not attempt to reset the Prisma Client outside setup files.",
|
|
3921
|
+
name: "src/database/client"
|
|
3922
|
+
},
|
|
3923
|
+
{
|
|
3924
|
+
message: "Do not use the generated Prisma types. Use the types exported from @neurosongs/types instead.",
|
|
3925
|
+
name: "@neurosongs/prisma-client/types"
|
|
3926
|
+
},
|
|
3927
|
+
{
|
|
3928
|
+
importNames: ["PrismaClient"],
|
|
3929
|
+
message: "Please use the PrismaClient from @neurosongs/types instead.",
|
|
3930
|
+
name: "@neurosongs/prisma-client/prisma"
|
|
3931
|
+
}
|
|
3932
|
+
] });
|
|
3933
|
+
var neurosongsBackEndRestrictedImports_default = neurosongsBackEndRestrictedImports;
|
|
3934
|
+
|
|
3851
3935
|
//#endregion
|
|
3852
3936
|
//#region src/configs/personal/neurosongsBackEnd.ts
|
|
3853
3937
|
const neurosongsBackEndConfig = [
|
|
3854
3938
|
{
|
|
3855
3939
|
name: "@alextheman/personal/neurosongs-back-end",
|
|
3856
|
-
rules: { "no-restricted-imports": ["error",
|
|
3857
|
-
{
|
|
3858
|
-
importNames: ["setPrismaClient"],
|
|
3859
|
-
message: "Do not attempt to reset the Prisma Client outside setup files.",
|
|
3860
|
-
name: "src/database/client"
|
|
3861
|
-
},
|
|
3862
|
-
{
|
|
3863
|
-
message: "Do not use the generated Prisma types. Use the types exported from @neurosongs/types instead.",
|
|
3864
|
-
name: "@neurosongs/prisma-client/types"
|
|
3865
|
-
},
|
|
3866
|
-
{
|
|
3867
|
-
importNames: ["PrismaClient"],
|
|
3868
|
-
message: "Please use the PrismaClient from @neurosongs/types instead.",
|
|
3869
|
-
name: "@neurosongs/prisma-client/prisma"
|
|
3870
|
-
}
|
|
3871
|
-
] }] }
|
|
3940
|
+
rules: { "no-restricted-imports": ["error", neurosongsBackEndRestrictedImports_default] }
|
|
3872
3941
|
},
|
|
3873
3942
|
{
|
|
3874
3943
|
files: ["src/database/**/*.ts", "tests/test-utilities/setup.ts"],
|
|
@@ -3885,33 +3954,32 @@ const neurosongsBackEndConfig = [
|
|
|
3885
3954
|
];
|
|
3886
3955
|
var neurosongsBackEnd_default = neurosongsBackEndConfig;
|
|
3887
3956
|
|
|
3957
|
+
//#endregion
|
|
3958
|
+
//#region src/configs/helpers/restrictedImports/neurosongsFrontEndRestrictedImports.ts
|
|
3959
|
+
const neurosongsFrontEndRestrictedImports = combineRestrictedImports_default(reactRestrictedImports_default, {
|
|
3960
|
+
paths: [{
|
|
3961
|
+
importNames: ["PrismaClient"],
|
|
3962
|
+
message: "Do not use the Prisma Client directly in the front-end. Query an endpoint from the back-end instead.",
|
|
3963
|
+
name: "@neurosongs/types"
|
|
3964
|
+
}, ...["LoaderProvider", "Loader"].map((importName) => {
|
|
3965
|
+
return {
|
|
3966
|
+
importNames: [importName],
|
|
3967
|
+
message: `Use the internal ${importName} from src/components/${importName} instead.`,
|
|
3968
|
+
name: "@alextheman/components"
|
|
3969
|
+
};
|
|
3970
|
+
})],
|
|
3971
|
+
patterns: [{
|
|
3972
|
+
group: ["@neurosongs/prisma-client"],
|
|
3973
|
+
message: "Do not use the Prisma Client directly in the front-end. Query an endpoint from the back-end instead."
|
|
3974
|
+
}]
|
|
3975
|
+
});
|
|
3976
|
+
var neurosongsFrontEndRestrictedImports_default = neurosongsFrontEndRestrictedImports;
|
|
3977
|
+
|
|
3888
3978
|
//#endregion
|
|
3889
3979
|
//#region src/configs/personal/neurosongsFrontEnd.ts
|
|
3890
3980
|
const neurosongsFrontEndConfig = [{
|
|
3891
3981
|
name: "@alextheman/personal/neurosongs-front-end",
|
|
3892
|
-
rules: { "no-restricted-imports": ["error",
|
|
3893
|
-
paths: [
|
|
3894
|
-
{
|
|
3895
|
-
importNames: ["PrismaClient"],
|
|
3896
|
-
message: "Do not use the Prisma Client directly in the front-end. Query an endpoint from the back-end instead.",
|
|
3897
|
-
name: "@neurosongs/types"
|
|
3898
|
-
},
|
|
3899
|
-
{
|
|
3900
|
-
importNames: ["LoaderProvider"],
|
|
3901
|
-
message: "Use the internal LoaderProvider from src/components/LoaderProvider instead.",
|
|
3902
|
-
name: "@alextheman/components"
|
|
3903
|
-
},
|
|
3904
|
-
{
|
|
3905
|
-
importNames: ["Loader"],
|
|
3906
|
-
message: "Use the internal Loader from src/components/Loader instead.",
|
|
3907
|
-
name: "@alextheman/components"
|
|
3908
|
-
}
|
|
3909
|
-
],
|
|
3910
|
-
patterns: [{
|
|
3911
|
-
group: ["@neurosongs/prisma-client"],
|
|
3912
|
-
message: "Do not use the Prisma Client directly in the front-end. Query an endpoint from the back-end instead."
|
|
3913
|
-
}]
|
|
3914
|
-
}] }
|
|
3982
|
+
rules: { "no-restricted-imports": ["error", neurosongsFrontEndRestrictedImports_default] }
|
|
3915
3983
|
}];
|
|
3916
3984
|
var neurosongsFrontEnd_default = neurosongsFrontEndConfig;
|
|
3917
3985
|
|
|
@@ -4068,24 +4136,6 @@ function fixOnCondition(fixable, fix) {
|
|
|
4068
4136
|
}
|
|
4069
4137
|
var fixOnCondition_default = fixOnCondition;
|
|
4070
4138
|
|
|
4071
|
-
//#endregion
|
|
4072
|
-
//#region src/utility/createRuleSchemaFromZodSchema.ts
|
|
4073
|
-
function createRuleSchemaFromZodSchema(schema$1) {
|
|
4074
|
-
return [omitProperties(z.toJSONSchema(schema$1), "$schema")];
|
|
4075
|
-
}
|
|
4076
|
-
var createRuleSchemaFromZodSchema_default = createRuleSchemaFromZodSchema;
|
|
4077
|
-
|
|
4078
|
-
//#endregion
|
|
4079
|
-
//#region src/utility/getImportSpecifiersAfterRemoving.ts
|
|
4080
|
-
function getImportSpecifiersAfterRemoving(context, specifiers, importToRemove) {
|
|
4081
|
-
return specifiers.filter((specifier) => {
|
|
4082
|
-
return !(specifier.imported.name === importToRemove);
|
|
4083
|
-
}).map((specifier) => {
|
|
4084
|
-
return context.sourceCode.getText(specifier);
|
|
4085
|
-
}).join(", ");
|
|
4086
|
-
}
|
|
4087
|
-
var getImportSpecifiersAfterRemoving_default = getImportSpecifiersAfterRemoving;
|
|
4088
|
-
|
|
4089
4139
|
//#endregion
|
|
4090
4140
|
//#region src/rules/consistent-test-function.ts
|
|
4091
4141
|
const validTestFunctionsSchema = z.enum(["test", "it"]);
|
|
@@ -4184,13 +4234,6 @@ const consistentTestFunction = createRule_default({
|
|
|
4184
4234
|
});
|
|
4185
4235
|
var consistent_test_function_default = consistentTestFunction;
|
|
4186
4236
|
|
|
4187
|
-
//#endregion
|
|
4188
|
-
//#region src/utility/checkCallExpression.ts
|
|
4189
|
-
function checkCallExpression(node, objectName, propertyName) {
|
|
4190
|
-
return node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && node.callee.object.name === objectName && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === propertyName;
|
|
4191
|
-
}
|
|
4192
|
-
var checkCallExpression_default = checkCallExpression;
|
|
4193
|
-
|
|
4194
4237
|
//#endregion
|
|
4195
4238
|
//#region src/rules/no-isolated-tests.ts
|
|
4196
4239
|
const noIsolatedTests = createRule_default({
|
|
@@ -4510,4 +4553,4 @@ var alexPlugin_default = alexPlugin;
|
|
|
4510
4553
|
var src_default = alexPlugin_default;
|
|
4511
4554
|
|
|
4512
4555
|
//#endregion
|
|
4513
|
-
export { checkCallExpression_default as checkCallExpression, createRuleSchemaFromZodSchema_default as createRuleSchemaFromZodSchema, src_default as default, fixOnCondition_default as fixOnCondition, getImportSpecifiersAfterRemoving_default as getImportSpecifiersAfterRemoving, parseConsistentTestFunctionOptions, parseNoNamespaceImportsOptions, parseNoRelativeImportsOptions, parseStandardiseErrorMessagesOptions, parseTestFunction, parseUseNormalizedImportsOptions, prettierRules_default as prettierRules, reactLanguageOptions_default as reactLanguageOptions, sortExports_default as sortExports, sortImports_default as sortImports, sortObjects_default as sortObjects, typeScriptLanguageOptions_default as typeScriptLanguageOptions, unusedVarsIgnorePatterns_default as unusedVarsIgnorePatterns, vitestConfig_default as vitestConfig };
|
|
4556
|
+
export { checkCallExpression_default as checkCallExpression, combineRestrictedImports_default as combineRestrictedImports, createRuleSchemaFromZodSchema_default as createRuleSchemaFromZodSchema, src_default as default, fixOnCondition_default as fixOnCondition, getImportSpecifiersAfterRemoving_default as getImportSpecifiersAfterRemoving, parseConsistentTestFunctionOptions, parseNoNamespaceImportsOptions, parseNoRelativeImportsOptions, parseStandardiseErrorMessagesOptions, parseTestFunction, parseUseNormalizedImportsOptions, prettierRules_default as prettierRules, reactLanguageOptions_default as reactLanguageOptions, sortExports_default as sortExports, sortImports_default as sortImports, sortObjects_default as sortObjects, typeScriptLanguageOptions_default as typeScriptLanguageOptions, unusedVarsIgnorePatterns_default as unusedVarsIgnorePatterns, vitestConfig_default as vitestConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/eslint-plugin",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.1",
|
|
4
4
|
"description": "A package to provide custom ESLint rules and configs",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,34 +14,9 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "tsdown && tsx src/utility/hashConfigChanges.ts",
|
|
19
|
-
"change-major": "pnpm version major -m \"Change version number to v%s\"",
|
|
20
|
-
"change-minor": "pnpm version minor -m \"Change version number to v%s\"",
|
|
21
|
-
"change-patch": "pnpm version patch -m \"Change version number to v%s\"",
|
|
22
|
-
"create-local-package": "pnpm run build && rm -f alextheman-eslint-plugin-*.tgz && pnpm pack",
|
|
23
|
-
"format": "pnpm run format-prettier && pnpm run format-eslint",
|
|
24
|
-
"format-and-build": "tsx src/utility/checkConfigChanges.ts || pnpm run build && pnpm run format",
|
|
25
|
-
"format-eslint": "eslint --fix --suppress-all \"src/**/*.ts\" \"tests/**/*.ts\" \"package.json\" && rm -f eslint-suppressions.json",
|
|
26
|
-
"format-prettier": "pnpm run format-prettier-typescript && pnpm run format-prettier-javascript",
|
|
27
|
-
"format-prettier-javascript": "prettier --write \"./**/*.js\"",
|
|
28
|
-
"format-prettier-typescript": "prettier --write --parser typescript \"./**/*.ts\"",
|
|
29
|
-
"lint": "pnpm run lint-tsc && pnpm run lint-eslint && pnpm run lint-prettier",
|
|
30
|
-
"lint-and-build": "tsx src/utility/checkConfigChanges.ts || pnpm run build && pnpm run lint",
|
|
31
|
-
"lint-eslint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\" \"package.json\"",
|
|
32
|
-
"lint-prettier": "pnpm run lint-prettier-typescript && pnpm run lint-prettier-javascript",
|
|
33
|
-
"lint-prettier-javascript": "prettier --check \"./**/*.js\"",
|
|
34
|
-
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
35
|
-
"lint-tsc": "tsc --noEmit",
|
|
36
|
-
"prepare": "husky",
|
|
37
|
-
"test": "vitest run",
|
|
38
|
-
"test-watch": "vitest",
|
|
39
|
-
"use-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
40
|
-
"use-local-utility": "dotenv -e .env -- sh -c 'UTILITY_PATH=${LOCAL_UTILITY_PATH:-../utility}; pnpm --dir \"$UTILITY_PATH\" run create-local-package && pnpm uninstall @alextheman/utility && pnpm install \"$UTILITY_PATH\"/alextheman-utility-*.tgz'"
|
|
41
|
-
},
|
|
42
17
|
"dependencies": {
|
|
43
|
-
"@alextheman/utility": "^3.4.
|
|
44
|
-
"@typescript-eslint/utils": "^8.48.
|
|
18
|
+
"@alextheman/utility": "^3.4.2",
|
|
19
|
+
"@typescript-eslint/utils": "^8.48.1",
|
|
45
20
|
"common-tags": "^1.8.2",
|
|
46
21
|
"zod": "^4.1.13"
|
|
47
22
|
},
|
|
@@ -51,7 +26,7 @@
|
|
|
51
26
|
"@types/eslint": "^9.6.1",
|
|
52
27
|
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
|
|
53
28
|
"@types/node": "^24.10.1",
|
|
54
|
-
"@typescript-eslint/rule-tester": "^8.48.
|
|
29
|
+
"@typescript-eslint/rule-tester": "^8.48.1",
|
|
55
30
|
"dotenv-cli": "^11.0.0",
|
|
56
31
|
"eslint": "^9.39.1",
|
|
57
32
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -68,13 +43,13 @@
|
|
|
68
43
|
"globals": "^16.5.0",
|
|
69
44
|
"husky": "^9.1.7",
|
|
70
45
|
"jsdom": "^27.2.0",
|
|
71
|
-
"prettier": "^3.7.
|
|
72
|
-
"tsdown": "^0.
|
|
73
|
-
"tsx": "^4.
|
|
46
|
+
"prettier": "^3.7.4",
|
|
47
|
+
"tsdown": "^0.17.0",
|
|
48
|
+
"tsx": "^4.21.0",
|
|
74
49
|
"typescript": "^5.9.3",
|
|
75
|
-
"typescript-eslint": "^8.48.
|
|
50
|
+
"typescript-eslint": "^8.48.1",
|
|
76
51
|
"vite-tsconfig-paths": "^5.1.4",
|
|
77
|
-
"vitest": "^4.0.
|
|
52
|
+
"vitest": "^4.0.15"
|
|
78
53
|
},
|
|
79
54
|
"peerDependencies": {
|
|
80
55
|
"@eslint/js": ">=9.0.0",
|
|
@@ -93,5 +68,29 @@
|
|
|
93
68
|
"vite-tsconfig-paths": ">=5.1.4",
|
|
94
69
|
"vitest": ">=4.0.13"
|
|
95
70
|
},
|
|
96
|
-
"
|
|
97
|
-
|
|
71
|
+
"scripts": {
|
|
72
|
+
"build": "tsdown && tsx src/utility/hashConfigChanges.ts",
|
|
73
|
+
"change-major": "pnpm version major -m \"Change version number to v%s\"",
|
|
74
|
+
"change-minor": "pnpm version minor -m \"Change version number to v%s\"",
|
|
75
|
+
"change-patch": "pnpm version patch -m \"Change version number to v%s\"",
|
|
76
|
+
"create-local-package": "pnpm run build && rm -f alextheman-eslint-plugin-*.tgz && pnpm pack",
|
|
77
|
+
"format": "pnpm run format-prettier && pnpm run format-eslint",
|
|
78
|
+
"format-and-build": "tsx src/utility/checkConfigChanges.ts || pnpm run build && pnpm run format",
|
|
79
|
+
"format-eslint": "eslint --fix --suppress-all \"src/**/*.ts\" \"tests/**/*.ts\" \"package.json\" && rm -f eslint-suppressions.json",
|
|
80
|
+
"format-prettier": "pnpm run format-prettier-typescript && pnpm run format-prettier-javascript",
|
|
81
|
+
"format-prettier-javascript": "prettier --write \"./**/*.js\"",
|
|
82
|
+
"format-prettier-typescript": "prettier --write --parser typescript \"./**/*.ts\"",
|
|
83
|
+
"lint": "pnpm run lint-tsc && pnpm run lint-eslint && pnpm run lint-prettier",
|
|
84
|
+
"lint-and-build": "tsx src/utility/checkConfigChanges.ts || pnpm run build && pnpm run lint",
|
|
85
|
+
"lint-eslint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\" \"package.json\"",
|
|
86
|
+
"lint-prettier": "pnpm run lint-prettier-typescript && pnpm run lint-prettier-javascript",
|
|
87
|
+
"lint-prettier-javascript": "prettier --check \"./**/*.js\"",
|
|
88
|
+
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
89
|
+
"lint-tsc": "tsc --noEmit",
|
|
90
|
+
"test": "vitest run",
|
|
91
|
+
"test-watch": "vitest",
|
|
92
|
+
"update-dependencies": "pnpm update --latest && pnpm update",
|
|
93
|
+
"use-live-utility": "pnpm uninstall @alextheman/utility && pnpm install @alextheman/utility",
|
|
94
|
+
"use-local-utility": "dotenv -e .env -- sh -c 'UTILITY_PATH=${LOCAL_UTILITY_PATH:-../utility}; pnpm --dir \"$UTILITY_PATH\" run create-local-package && pnpm uninstall @alextheman/utility && pnpm install \"$UTILITY_PATH\"/alextheman-utility-*.tgz'"
|
|
95
|
+
}
|
|
96
|
+
}
|