eslint-config-agent 1.0.21 → 1.0.22
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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. See [Conven
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
## [1.0.22](https://github.com/tupe12334/eslint-config/compare/v1.0.21...v1.0.22) (2025-09-04)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add max-lines and max-lines-per-function rules with configurations and tests ([218f29c](https://github.com/tupe12334/eslint-config/commit/218f29ca497ca1b49e027f3e33f87cf836e7ff02))
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* resolve linting issues for release ([3c812cd](https://github.com/tupe12334/eslint-config/commit/3c812cd223f169360cb0d1520e401a17a6a9b960))
|
|
16
|
+
|
|
7
17
|
## [1.0.21](https://github.com/tupe12334/eslint-config/compare/v1.0.19...v1.0.21) (2025-09-04)
|
|
8
18
|
|
|
9
19
|
### Bug Fixes
|
package/index.js
CHANGED
|
@@ -7,6 +7,8 @@ import reactPlugin from "eslint-plugin-react";
|
|
|
7
7
|
import importPlugin from "eslint-plugin-import";
|
|
8
8
|
import globals from "globals";
|
|
9
9
|
import noTrailingSpacesConfig from "./rules/no-trailing-spaces/index.js";
|
|
10
|
+
import { maxFunctionLinesWarning, maxFunctionLinesError } from "./rules/max-function-lines/index.js";
|
|
11
|
+
import { maxFileLinesWarning, maxFileLinesError } from "./rules/max-file-lines/index.js";
|
|
10
12
|
|
|
11
13
|
// Conditionally import preact plugin if available
|
|
12
14
|
let preactPlugin = null;
|
|
@@ -41,10 +43,8 @@ const sharedRules = {
|
|
|
41
43
|
"import/first": "off",
|
|
42
44
|
"import/prefer-default-export": "off",
|
|
43
45
|
"react/react-in-jsx-scope": "off",
|
|
44
|
-
"max-lines-per-function":
|
|
45
|
-
|
|
46
|
-
{ max: 100, skipBlankLines: true, skipComments: true },
|
|
47
|
-
],
|
|
46
|
+
"max-lines-per-function": maxFunctionLinesWarning,
|
|
47
|
+
"max-lines": maxFileLinesWarning,
|
|
48
48
|
"react/jsx-filename-extension": ["error", { extensions: [".tsx", ".jsx"] }],
|
|
49
49
|
semi: "off",
|
|
50
50
|
"react/function-component-definition": "off",
|
|
@@ -73,8 +73,10 @@ const sharedRestrictedSyntax = [
|
|
|
73
73
|
message: "Optional chaining is not allowed.",
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
|
-
selector:
|
|
77
|
-
|
|
76
|
+
selector:
|
|
77
|
+
"MemberExpression[object.type='MemberExpression'][object.object.name='process'][object.property.name='env']",
|
|
78
|
+
message:
|
|
79
|
+
"Direct access to process.env properties is not allowed. Use a configuration object or environment validation instead.",
|
|
78
80
|
},
|
|
79
81
|
{
|
|
80
82
|
selector: "CallExpression[optional=true]",
|
|
@@ -261,7 +263,6 @@ const config = [
|
|
|
261
263
|
},
|
|
262
264
|
js.configs.recommended,
|
|
263
265
|
|
|
264
|
-
|
|
265
266
|
// TypeScript and TSX files
|
|
266
267
|
{
|
|
267
268
|
files: ["**/*.ts", "**/*.tsx"],
|
|
@@ -500,10 +501,7 @@ const config = [
|
|
|
500
501
|
},
|
|
501
502
|
rules: {
|
|
502
503
|
...sharedRules,
|
|
503
|
-
"no-restricted-syntax": [
|
|
504
|
-
"error",
|
|
505
|
-
...sharedRestrictedSyntax,
|
|
506
|
-
],
|
|
504
|
+
"no-restricted-syntax": ["error", ...sharedRestrictedSyntax],
|
|
507
505
|
},
|
|
508
506
|
},
|
|
509
507
|
|
|
@@ -769,8 +767,10 @@ const config = [
|
|
|
769
767
|
"error",
|
|
770
768
|
// Process.env rule (applies to all file types)
|
|
771
769
|
{
|
|
772
|
-
selector:
|
|
773
|
-
|
|
770
|
+
selector:
|
|
771
|
+
"MemberExpression[object.type='MemberExpression'][object.object.name='process'][object.property.name='env']",
|
|
772
|
+
message:
|
|
773
|
+
"Direct access to process.env properties is not allowed. Use a configuration object or environment validation instead.",
|
|
774
774
|
},
|
|
775
775
|
// Switch case rules as errors
|
|
776
776
|
{
|
|
@@ -853,6 +853,30 @@ const config = [
|
|
|
853
853
|
},
|
|
854
854
|
},
|
|
855
855
|
|
|
856
|
+
// Function and file length rules - strict error thresholds
|
|
857
|
+
{
|
|
858
|
+
files: ["**/*.{ts,tsx,js,jsx}"],
|
|
859
|
+
rules: {
|
|
860
|
+
// Function length: error at 70+ lines
|
|
861
|
+
"max-lines-per-function": maxFunctionLinesError,
|
|
862
|
+
// File length: error at 100+ lines
|
|
863
|
+
"max-lines": maxFileLinesError,
|
|
864
|
+
},
|
|
865
|
+
},
|
|
866
|
+
|
|
867
|
+
// Disable file length rules for configuration and spec files
|
|
868
|
+
{
|
|
869
|
+
files: [
|
|
870
|
+
"index.js", // Main configuration file
|
|
871
|
+
"**/rules/**/*.spec.js", // Spec files in rules directory
|
|
872
|
+
"**/scripts/**/*.js", // Script files
|
|
873
|
+
],
|
|
874
|
+
rules: {
|
|
875
|
+
"max-lines": "off",
|
|
876
|
+
"max-lines-per-function": "off",
|
|
877
|
+
},
|
|
878
|
+
},
|
|
879
|
+
|
|
856
880
|
// Allow default exports in configuration files (must be last to override)
|
|
857
881
|
{
|
|
858
882
|
files: [
|
package/package.json
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule configuration for max-lines
|
|
3
|
+
*
|
|
4
|
+
* This rule enforces a maximum number of lines per file to encourage
|
|
5
|
+
* smaller, more maintainable files and better separation of concerns.
|
|
6
|
+
*
|
|
7
|
+
* Warnings at >70 lines, errors at >100 lines
|
|
8
|
+
*
|
|
9
|
+
* @see https://eslint.org/docs/latest/rules/max-lines
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// Warning configuration (70 lines)
|
|
13
|
+
export const warningRule = "warn";
|
|
14
|
+
export const warningOptions = {
|
|
15
|
+
max: 70,
|
|
16
|
+
skipBlankLines: true,
|
|
17
|
+
skipComments: true,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Error configuration (100 lines)
|
|
21
|
+
export const errorRule = "error";
|
|
22
|
+
export const errorOptions = {
|
|
23
|
+
max: 100,
|
|
24
|
+
skipBlankLines: true,
|
|
25
|
+
skipComments: true,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Export the warning rule configuration (applied first)
|
|
30
|
+
* Can be used in ESLint config as:
|
|
31
|
+
* "max-lines": maxFileLinesWarning
|
|
32
|
+
*/
|
|
33
|
+
export const maxFileLinesWarning = [warningRule, warningOptions];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Export the error rule configuration (applied later to override)
|
|
37
|
+
* Can be used in ESLint config as:
|
|
38
|
+
* "max-lines": maxFileLinesError
|
|
39
|
+
*/
|
|
40
|
+
export const maxFileLinesError = [errorRule, errorOptions];
|
|
41
|
+
|
|
42
|
+
// Default export is the warning configuration
|
|
43
|
+
export default maxFileLinesWarning;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* global process */
|
|
2
|
+
import {
|
|
3
|
+
warningRule,
|
|
4
|
+
warningOptions,
|
|
5
|
+
errorRule,
|
|
6
|
+
errorOptions,
|
|
7
|
+
maxFileLinesWarning,
|
|
8
|
+
maxFileLinesError
|
|
9
|
+
} from "./index.js";
|
|
10
|
+
|
|
11
|
+
console.log("Testing max-file-lines rule configuration exports...");
|
|
12
|
+
|
|
13
|
+
// Test warning configuration
|
|
14
|
+
console.log("\n📋 Warning Configuration:");
|
|
15
|
+
console.log("Rule level:", warningRule);
|
|
16
|
+
console.log("Options:", warningOptions);
|
|
17
|
+
console.log("Complete config:", maxFileLinesWarning);
|
|
18
|
+
|
|
19
|
+
// Validate warning configuration
|
|
20
|
+
if (warningRule === "warn" &&
|
|
21
|
+
warningOptions.max === 70 &&
|
|
22
|
+
warningOptions.skipBlankLines === true &&
|
|
23
|
+
warningOptions.skipComments === true) {
|
|
24
|
+
console.log("✅ Warning configuration is correct");
|
|
25
|
+
} else {
|
|
26
|
+
console.log("❌ Warning configuration is incorrect");
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Test error configuration
|
|
31
|
+
console.log("\n📋 Error Configuration:");
|
|
32
|
+
console.log("Rule level:", errorRule);
|
|
33
|
+
console.log("Options:", errorOptions);
|
|
34
|
+
console.log("Complete config:", maxFileLinesError);
|
|
35
|
+
|
|
36
|
+
// Validate error configuration
|
|
37
|
+
if (errorRule === "error" &&
|
|
38
|
+
errorOptions.max === 100 &&
|
|
39
|
+
errorOptions.skipBlankLines === true &&
|
|
40
|
+
errorOptions.skipComments === true) {
|
|
41
|
+
console.log("✅ Error configuration is correct");
|
|
42
|
+
} else {
|
|
43
|
+
console.log("❌ Error configuration is incorrect");
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log("\n✅ All max-file-lines configuration tests passed!");
|
|
48
|
+
|
|
49
|
+
// Test that the configurations are properly formatted for ESLint
|
|
50
|
+
console.log("\n📋 ESLint Configuration Format:");
|
|
51
|
+
console.log("Warning format:", JSON.stringify(maxFileLinesWarning));
|
|
52
|
+
console.log("Error format:", JSON.stringify(maxFileLinesError));
|
|
53
|
+
|
|
54
|
+
// Validate ESLint format
|
|
55
|
+
if (Array.isArray(maxFileLinesWarning) &&
|
|
56
|
+
maxFileLinesWarning.length === 2 &&
|
|
57
|
+
maxFileLinesWarning[0] === "warn" &&
|
|
58
|
+
typeof maxFileLinesWarning[1] === "object") {
|
|
59
|
+
console.log("✅ Warning ESLint format is correct");
|
|
60
|
+
} else {
|
|
61
|
+
console.log("❌ Warning ESLint format is incorrect");
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (Array.isArray(maxFileLinesError) &&
|
|
66
|
+
maxFileLinesError.length === 2 &&
|
|
67
|
+
maxFileLinesError[0] === "error" &&
|
|
68
|
+
typeof maxFileLinesError[1] === "object") {
|
|
69
|
+
console.log("✅ Error ESLint format is correct");
|
|
70
|
+
} else {
|
|
71
|
+
console.log("❌ Error ESLint format is incorrect");
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
console.log("\n🎉 All tests completed successfully!");
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule configuration for max-lines-per-function
|
|
3
|
+
*
|
|
4
|
+
* This rule enforces a maximum number of lines per function to encourage
|
|
5
|
+
* smaller, more maintainable functions.
|
|
6
|
+
*
|
|
7
|
+
* Warnings at >50 lines, errors at >70 lines
|
|
8
|
+
*
|
|
9
|
+
* @see https://eslint.org/docs/latest/rules/max-lines-per-function
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// Warning configuration (50 lines)
|
|
13
|
+
export const warningRule = "warn";
|
|
14
|
+
export const warningOptions = {
|
|
15
|
+
max: 50,
|
|
16
|
+
skipBlankLines: true,
|
|
17
|
+
skipComments: true,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Error configuration (70 lines)
|
|
21
|
+
export const errorRule = "error";
|
|
22
|
+
export const errorOptions = {
|
|
23
|
+
max: 70,
|
|
24
|
+
skipBlankLines: true,
|
|
25
|
+
skipComments: true,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Export the warning rule configuration (applied first)
|
|
30
|
+
* Can be used in ESLint config as:
|
|
31
|
+
* "max-lines-per-function": maxFunctionLinesWarning
|
|
32
|
+
*/
|
|
33
|
+
export const maxFunctionLinesWarning = [warningRule, warningOptions];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Export the error rule configuration (applied later to override)
|
|
37
|
+
* Can be used in ESLint config as:
|
|
38
|
+
* "max-lines-per-function": maxFunctionLinesError
|
|
39
|
+
*/
|
|
40
|
+
export const maxFunctionLinesError = [errorRule, errorOptions];
|
|
41
|
+
|
|
42
|
+
// Default export is the warning configuration
|
|
43
|
+
export default maxFunctionLinesWarning;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* global process */
|
|
2
|
+
import {
|
|
3
|
+
warningRule,
|
|
4
|
+
warningOptions,
|
|
5
|
+
errorRule,
|
|
6
|
+
errorOptions,
|
|
7
|
+
maxFunctionLinesWarning,
|
|
8
|
+
maxFunctionLinesError
|
|
9
|
+
} from "./index.js";
|
|
10
|
+
|
|
11
|
+
console.log("Testing max-function-lines rule configuration exports...");
|
|
12
|
+
|
|
13
|
+
// Test warning configuration
|
|
14
|
+
console.log("\n📋 Warning Configuration:");
|
|
15
|
+
console.log("Rule level:", warningRule);
|
|
16
|
+
console.log("Options:", warningOptions);
|
|
17
|
+
console.log("Complete config:", maxFunctionLinesWarning);
|
|
18
|
+
|
|
19
|
+
// Validate warning configuration
|
|
20
|
+
if (warningRule === "warn" &&
|
|
21
|
+
warningOptions.max === 50 &&
|
|
22
|
+
warningOptions.skipBlankLines === true &&
|
|
23
|
+
warningOptions.skipComments === true) {
|
|
24
|
+
console.log("✅ Warning configuration is correct");
|
|
25
|
+
} else {
|
|
26
|
+
console.log("❌ Warning configuration is incorrect");
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Test error configuration
|
|
31
|
+
console.log("\n📋 Error Configuration:");
|
|
32
|
+
console.log("Rule level:", errorRule);
|
|
33
|
+
console.log("Options:", errorOptions);
|
|
34
|
+
console.log("Complete config:", maxFunctionLinesError);
|
|
35
|
+
|
|
36
|
+
// Validate error configuration
|
|
37
|
+
if (errorRule === "error" &&
|
|
38
|
+
errorOptions.max === 70 &&
|
|
39
|
+
errorOptions.skipBlankLines === true &&
|
|
40
|
+
errorOptions.skipComments === true) {
|
|
41
|
+
console.log("✅ Error configuration is correct");
|
|
42
|
+
} else {
|
|
43
|
+
console.log("❌ Error configuration is incorrect");
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log("\n✅ All max-function-lines configuration tests passed!");
|
|
48
|
+
|
|
49
|
+
// Test that the configurations are properly formatted for ESLint
|
|
50
|
+
console.log("\n📋 ESLint Configuration Format:");
|
|
51
|
+
console.log("Warning format:", JSON.stringify(maxFunctionLinesWarning));
|
|
52
|
+
console.log("Error format:", JSON.stringify(maxFunctionLinesError));
|
|
53
|
+
|
|
54
|
+
// Validate ESLint format
|
|
55
|
+
if (Array.isArray(maxFunctionLinesWarning) &&
|
|
56
|
+
maxFunctionLinesWarning.length === 2 &&
|
|
57
|
+
maxFunctionLinesWarning[0] === "warn" &&
|
|
58
|
+
typeof maxFunctionLinesWarning[1] === "object") {
|
|
59
|
+
console.log("✅ Warning ESLint format is correct");
|
|
60
|
+
} else {
|
|
61
|
+
console.log("❌ Warning ESLint format is incorrect");
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (Array.isArray(maxFunctionLinesError) &&
|
|
66
|
+
maxFunctionLinesError.length === 2 &&
|
|
67
|
+
maxFunctionLinesError[0] === "error" &&
|
|
68
|
+
typeof maxFunctionLinesError[1] === "object") {
|
|
69
|
+
console.log("✅ Error ESLint format is correct");
|
|
70
|
+
} else {
|
|
71
|
+
console.log("❌ Error ESLint format is incorrect");
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
console.log("\n🎉 All tests completed successfully!");
|