-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
123 lines (115 loc) · 4.21 KB
/
eslint.config.mjs
File metadata and controls
123 lines (115 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* ==========================================================================
eslint.config.mjs
SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later
This file is part of Network Pro.
========================================================================== */
import js from "@eslint/js"; // Provides ESLint core rules and recommended config
import eslintConfigPrettier from "eslint-config-prettier"; // Prettier config to disable conflicting ESLint rules
import jsdocPlugin from "eslint-plugin-jsdoc"; // JSDoc plugin
import sveltePlugin from "eslint-plugin-svelte"; // Svelte plugin
import globals from "globals";
import svelteParser from "svelte-eslint-parser"; // Svelte parser
const GLOBALS = {
...globals.browser,
...globals.node,
self: "readonly",
location: "readonly",
indexedDB: "readonly",
...globals.vitest, // Add Vitest globals for test functions like afterEach, describe, etc.
};
// Define general ESLint rules (non-Svelte-specific)
const ESLINT_RULES = {
indent: "off", // Turn off the 'indent' rule, managed by Prettier
quotes: "off", // Turn off the 'quotes' rule, managed by Prettier
semi: "off", // Turn off the 'semi' rule, managed by Prettier
};
export default [
// Global ignores
{
ignores: [
".*", // Hidden files
"*.xml", // XML files
"**/.cache/**", // Cache directories
"**/.vscode/**", // VSCode-specific files
"**/coverage/**", // Coverage reports
"**/build/**", // Distribution files
"package.json", // NPM package manifest
"package-lock.json", // NPM lockfile
"node_modules/", // Node.js dependencies
".vite/", // Vite-specific cache directory
"*.lock", // Lock files
".env*", // Environment files
],
},
// General JavaScript/Node.js configuration
{
files: ["**/*.mjs", "**/*.js"],
languageOptions: {
globals: GLOBALS,
ecmaVersion: "latest",
sourceType: "module",
},
plugins: {
jsdoc: jsdocPlugin, // Include JSDoc plugin
},
rules: {
...js.configs.recommended.rules, // ESLint's core recommended rules (scoped)
...eslintConfigPrettier.rules, // Prettier config to disable conflicting ESLint rules (scoped)
...ESLINT_RULES, // Additional custom rules
"no-unused-vars": ["error", { argsIgnorePattern: "^_" }], // Ignore unused variables starting with an underscore
"jsdoc/check-alignment": "warn", // Ensure JSDoc block tags are aligned
"jsdoc/check-param-names": "warn", // Checks parameter names in JSDoc
// Updated rule to allow the @updated tag
"jsdoc/check-tag-names": [
"warn",
{
definedTags: ["updated"],
},
],
"jsdoc/check-types": "warn", // Checks if types in JSDoc are defined correctly
"jsdoc/require-param": "warn", // Requires @param in JSDoc
"jsdoc/require-returns": "warn", // Requires @returns in JSDoc
"jsdoc/require-jsdoc": [
"warn",
{
publicOnly: true,
require: {
FunctionDeclaration: true,
MethodDefinition: true,
ClassDeclaration: true,
},
},
],
},
},
// Svelte-specific configuration
{
files: ["**/*.svelte"],
plugins: { svelte: sveltePlugin }, // Use imported Svelte plugin
languageOptions: {
parser: svelteParser, // Use imported Svelte parser
globals: GLOBALS, // Your global variables
ecmaVersion: "latest", // Use "latest" for Svelte to leverage modern features
sourceType: "module",
},
rules: {
...sveltePlugin.configs.recommended.rules, // Svelte recommended rules
...sveltePlugin.configs.prettier.rules, // Prettier compatibility for Svelte
"svelte/no-at-html-tags": "warn", // Warn on use of @html (security risk)
"svelte/require-optimized-style-attribute": "warn", // Recommend optimized style attributes
},
},
// Vitest-specific configuration
{
files: ["**/*.test.js", "**/*.spec.js", "**/vitest-setup-client.js"], // Test-related files
languageOptions: {
globals: {
...GLOBALS,
afterEach: "readonly", // Explicitly declare afterEach as a global
},
},
rules: {
"no-undef": "off", // Turn off no-undef for test globals
},
},
];