-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
102 lines (97 loc) · 2.56 KB
/
eslint.config.mjs
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
/*
* This program has been developed by students from the bachelor
* Computer Science at Utrecht University within the Software Project course.
*
* © Copyright Utrecht University
* (Department of Information and Computing Sciences)
*/
import { FlatCompat } from "@eslint/eslintrc";
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
const rule = {
create(context) {
const commentText =
"\n" +
" * This program has been developed by students from the bachelor\n" +
" * Computer Science at Utrecht University within the Software Project course.\n" +
" *\n" +
" * © Copyright Utrecht University\n" +
" * (Department of Information and Computing Sciences)\n" +
" ";
return {
Program(node) {
const comments = context.sourceCode.getCommentsBefore(node.body[0]);
if (
!(
comments.length > 0 &&
comments[0].range[0] === 0 &&
comments[0].value == commentText
)
) {
context.report({
fix(fixer) {
return fixer.insertTextBefore(
comments[0] ?? node.body[0],
`/*${commentText}*/\n\n`
);
},
message: "Copyright comment not found at the top",
node: comments[0] ?? node.body[0]
});
return;
}
}
};
},
meta: {
docs: {
category: "Mandatory",
description:
"Ensure a specific comment exists at the top of the document",
recommended: true
},
fixable: "code",
type: "maintenance"
}
};
const plugin = { rules: { "enforce-copyright-comment": rule } };
const compat = new FlatCompat();
export default tseslint.config(
{
ignores: ["**/*.config.*"],
plugins: { custom: plugin },
rules: { "custom/enforce-copyright-comment": "error" }
},
eslint.configs.recommended,
...tseslint.configs.recommended,
...compat.extends(
"plugin:perfectionist/recommended-natural",
"plugin:unicorn/recommended"
),
{
rules: {
"unicorn/filename-case": [
"error",
{
case: "camelCase"
}
],
"perfectionist/sort-interfaces": "off",
"perfectionist/sort-objects": "off",
"perfectionist/sort-object-types": "off",
"unicorn/prefer-top-level-await": "off",
"unicorn/prevent-abbreviations": [
"error",
{
replacements: {
e: false,
i: false
}
}
]
}
},
{
ignores: ["build", "data", "dist", "README.md"]
}
);