@commencis/eslint-plugin 2.1.0 → 3.0.0

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
@@ -1,5 +1,11 @@
1
1
  # @commencis/eslint-plugin
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [BreakingChange]: Introducing v3 - With cleaner dependencies and structure. Check readme files for implementations. ([#414](https://github.com/Commencis/js-toolkit/pull/414))
8
+
3
9
  ## 2.1.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -1,42 +1,8 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all2) => {
7
- for (var name in all2)
8
- __defProp(target, name, { get: all2[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- default: () => index_default
24
- });
25
- module.exports = __toCommonJS(index_exports);
1
+ let _typescript_eslint_utils = require("@typescript-eslint/utils");
26
2
 
27
- // src/configs/all.ts
28
- var all = {
29
- "@commencis/copyright-text": "error"
30
- };
31
-
32
- // src/configs/recommended.ts
33
- var recommended = {
34
- "@commencis/copyright-text": "off"
35
- };
36
-
37
- // src/constants/copyright.ts
38
- var DEFAULT_START_YEAR = 2017;
39
- var COPYRIGHT_TEXT = `
3
+ //#region src/constants/copyright.ts
4
+ const DEFAULT_START_YEAR = 2017;
5
+ const COPYRIGHT_TEXT = `
40
6
  * Copyright {startYear}-{currentYear} Commencis. All Rights Reserved.
41
7
  *
42
8
  * Save to the extent permitted by law, you may not use, copy, modify,
@@ -45,174 +11,108 @@ var COPYRIGHT_TEXT = `
45
11
  * Any reproduction of this material must contain this notice.
46
12
  `.trim();
47
13
 
48
- // src/constants/docsBaseUrl.ts
49
- var DOCS_BASE_URL = "https://github.com/Commencis/js-toolkit/tree/main/packages/eslint-plugin/docs/rules/";
50
-
51
- // src/utils/createRule.ts
52
- var import_utils = require("@typescript-eslint/utils");
14
+ //#endregion
15
+ //#region src/constants/docsBaseUrl.ts
16
+ const DOCS_BASE_URL = "https://github.com/Commencis/js-toolkit/tree/main/packages/eslint-plugin/docs/rules/";
53
17
 
54
- // src/utils/getDocsUrl.ts
18
+ //#endregion
19
+ //#region src/utils/getDocsUrl.ts
55
20
  function getDocsUrls(ruleName) {
56
- return `${DOCS_BASE_URL}${ruleName}.md`;
21
+ return `${DOCS_BASE_URL}${ruleName}.md`;
57
22
  }
58
23
 
59
- // src/utils/createRule.ts
60
- var createRule = import_utils.ESLintUtils.RuleCreator((name) => getDocsUrls(name));
24
+ //#endregion
25
+ //#region src/utils/createRule.ts
26
+ const createRule = _typescript_eslint_utils.ESLintUtils.RuleCreator((name$1) => getDocsUrls(name$1));
61
27
 
62
- // src/utils/getCopyrightText.ts
28
+ //#endregion
29
+ //#region src/utils/getCopyrightText.ts
63
30
  function getCopyrightText(startYear, isHtml) {
64
- const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
65
- const formattedText = COPYRIGHT_TEXT.replace(
66
- /{startYear}/g,
67
- startYear.toString()
68
- ).replace(/{currentYear}/g, currentYear.toString());
69
- if (isHtml) {
70
- return `<!--
71
- ${formattedText}
72
- -->`;
73
- }
74
- return `/*
75
- ${formattedText}
76
- */`;
31
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
32
+ const formattedText = COPYRIGHT_TEXT.replace(/{startYear}/g, startYear.toString()).replace(/{currentYear}/g, currentYear.toString());
33
+ if (isHtml) return `<!--\n ${formattedText}\n-->`;
34
+ return `/*\n ${formattedText}\n */`;
77
35
  }
78
36
 
79
- // src/utils/validateCommencisCopyright.ts
80
- var import_utils2 = require("@typescript-eslint/utils");
37
+ //#endregion
38
+ //#region src/utils/validateCommencisCopyright.ts
81
39
  function validateCommencisCopyright(comment) {
82
- if (typeof comment === "string") {
83
- return comment.includes("Commencis") && comment.includes("Copyright");
84
- }
85
- return !!comment && comment.type === import_utils2.AST_TOKEN_TYPES.Block && comment.value.includes("Commencis") && comment.value.includes("Copyright");
40
+ if (typeof comment === "string") return comment.includes("Commencis") && comment.includes("Copyright");
41
+ return !!comment && comment.type === _typescript_eslint_utils.AST_TOKEN_TYPES.Block && comment.value.includes("Commencis") && comment.value.includes("Copyright");
86
42
  }
87
43
 
88
- // src/rules/copyright-text.ts
44
+ //#endregion
45
+ //#region src/rules/copyright-text.ts
89
46
  var copyright_text_default = createRule({
90
- name: "copyright-text",
91
- meta: {
92
- type: "suggestion",
93
- docs: {
94
- description: "Ensure files start with the required Commencis copyright text"
95
- },
96
- messages: {
97
- missingCopyright: "File must start with the required Commencis copyright text with correct dates."
98
- },
99
- schema: [
100
- {
101
- type: "object",
102
- properties: {
103
- startYear: {
104
- type: "number",
105
- default: DEFAULT_START_YEAR
106
- }
107
- },
108
- additionalProperties: false
109
- }
110
- ],
111
- fixable: "code"
112
- },
113
- defaultOptions: [{ startYear: DEFAULT_START_YEAR }],
114
- create(context, [options]) {
115
- const startYear = options.startYear ?? DEFAULT_START_YEAR;
116
- const isHtml = context.filename.endsWith(".vue");
117
- const expectedCopyrightText = getCopyrightText(startYear, isHtml);
118
- return {
119
- Program(node) {
120
- const sourceCode = context.sourceCode.getText();
121
- const firstComment = context.sourceCode.getAllComments()[0];
122
- const trimmedText = sourceCode.trimStart();
123
- const isCopyrightValid = trimmedText.startsWith(expectedCopyrightText);
124
- if (!isCopyrightValid) {
125
- const isCommencisCopyrightExists = validateCommencisCopyright(
126
- isHtml ? trimmedText : firstComment
127
- );
128
- context.report({
129
- node,
130
- messageId: "missingCopyright",
131
- fix(fixer) {
132
- const insertText = `${expectedCopyrightText}
133
-
134
- `;
135
- return isCommencisCopyrightExists ? isHtml ? fixer.replaceTextRange([0, insertText.length], insertText) : fixer.replaceText(firstComment, insertText) : fixer.insertTextBeforeRange([0, 0], insertText);
136
- }
137
- });
138
- }
139
- }
140
- };
141
- }
47
+ name: "copyright-text",
48
+ meta: {
49
+ type: "suggestion",
50
+ docs: { description: "Ensure files start with the required Commencis copyright text" },
51
+ messages: { missingCopyright: "File must start with the required Commencis copyright text with correct dates." },
52
+ schema: [{
53
+ type: "object",
54
+ properties: { startYear: {
55
+ type: "number",
56
+ default: DEFAULT_START_YEAR
57
+ } },
58
+ additionalProperties: false
59
+ }],
60
+ fixable: "code"
61
+ },
62
+ defaultOptions: [{ startYear: DEFAULT_START_YEAR }],
63
+ create(context, [options]) {
64
+ const startYear = options.startYear ?? DEFAULT_START_YEAR;
65
+ const isHtml = context.filename.endsWith(".vue");
66
+ const expectedCopyrightText = getCopyrightText(startYear, isHtml);
67
+ return { Program(node) {
68
+ const sourceCode = context.sourceCode.getText();
69
+ const firstComment = context.sourceCode.getAllComments()[0];
70
+ const trimmedText = sourceCode.trimStart();
71
+ if (!trimmedText.startsWith(expectedCopyrightText)) {
72
+ const isCommencisCopyrightExists = validateCommencisCopyright(isHtml ? trimmedText : firstComment);
73
+ context.report({
74
+ node,
75
+ messageId: "missingCopyright",
76
+ fix(fixer) {
77
+ const insertText = `${expectedCopyrightText}\n\n`;
78
+ return isCommencisCopyrightExists ? isHtml ? fixer.replaceTextRange([0, insertText.length], insertText) : fixer.replaceText(firstComment, insertText) : fixer.insertTextBeforeRange([0, 0], insertText);
79
+ }
80
+ });
81
+ }
82
+ } };
83
+ }
142
84
  });
143
85
 
144
- // src/rules/index.ts
145
- var rules_default = {
146
- "copyright-text": copyright_text_default
147
- };
86
+ //#endregion
87
+ //#region src/rules/index.ts
88
+ var rules_default = { "copyright-text": copyright_text_default };
148
89
 
149
- // package.json
150
- var package_default = {
151
- name: "@commencis/eslint-plugin",
152
- version: "2.1.0",
153
- description: "Commencis ESLint plugin",
154
- author: "Commencis WEB Team",
155
- license: "Apache-2.0",
156
- type: "module",
157
- homepage: "https://github.com/Commencis/js-toolkit/tree/main/packages/eslint-plugin#readme",
158
- bugs: {
159
- url: "https://github.com/Commencis/js-toolkit/issues"
160
- },
161
- repository: {
162
- type: "git",
163
- url: "https://github.com/Commencis/js-toolkit.git",
164
- directory: "packages/eslint-plugin"
165
- },
166
- publishConfig: {
167
- access: "public"
168
- },
169
- main: "dist/index.js",
170
- files: [
171
- "dist",
172
- "*.md",
173
- "LICENSE"
174
- ],
175
- exports: {
176
- types: "./dist/index.d.ts",
177
- import: "./dist/index.js",
178
- require: "./dist/index.cjs"
179
- },
180
- scripts: {
181
- dev: "tsup --watch",
182
- build: "tsup",
183
- "lint:types": "tsc --noEmit"
184
- },
185
- dependencies: {
186
- "@typescript-eslint/utils": "8.49.0"
187
- },
188
- devDependencies: {
189
- "@commencis/ts-config": "1.0.0",
190
- tsup: "8.5.1",
191
- typescript: "5.9.3"
192
- }
193
- };
90
+ //#endregion
91
+ //#region package.json
92
+ var name = "@commencis/eslint-plugin";
93
+ var version = "3.0.0";
194
94
 
195
- // src/index.ts
196
- var plugin = {
197
- meta: {
198
- name: package_default.name,
199
- version: package_default.version
200
- },
201
- configs: {},
202
- rules: rules_default
95
+ //#endregion
96
+ //#region src/index.ts
97
+ const plugin = {
98
+ meta: {
99
+ name,
100
+ version
101
+ },
102
+ configs: {},
103
+ rules: rules_default
203
104
  };
204
105
  Object.assign(plugin.configs, {
205
- all: [
206
- {
207
- plugins: { "@commencis": plugin },
208
- rules: all
209
- }
210
- ],
211
- recommended: [
212
- {
213
- plugins: { "@commencis": plugin },
214
- rules: recommended
215
- }
216
- ]
106
+ all: [{
107
+ plugins: { "@commencis": plugin },
108
+ rules: { "@commencis/copyright-text": "error" }
109
+ }],
110
+ recommended: [{
111
+ plugins: { "@commencis": plugin },
112
+ rules: { "@commencis/copyright-text": "off" }
113
+ }]
217
114
  });
218
- var index_default = plugin;
115
+ var src_default = plugin;
116
+
117
+ //#endregion
118
+ module.exports = src_default;
package/dist/index.d.cts CHANGED
@@ -1,16 +1,18 @@
1
- import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
1
+ import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
2
2
 
3
+ //#region src/index.d.ts
3
4
  declare const plugin: {
4
- meta: {
5
- name: string;
6
- version: string;
7
- };
8
- configs: {};
9
- rules: {
10
- 'copyright-text': _typescript_eslint_utils_ts_eslint.RuleModule<"missingCopyright", [{
11
- startYear?: number;
12
- }], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
5
+ meta: {
6
+ name: string;
7
+ version: string;
8
+ };
9
+ configs: {};
10
+ rules: {
11
+ 'copyright-text': _typescript_eslint_utils_ts_eslint0.RuleModule<"missingCopyright", [{
12
+ startYear?: number;
13
+ }], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
14
+ name: string;
13
15
  };
16
+ };
14
17
  };
15
-
16
- export { plugin as default };
18
+ export = plugin;
@@ -0,0 +1,19 @@
1
+ import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
2
+
3
+ //#region src/index.d.ts
4
+ declare const plugin: {
5
+ meta: {
6
+ name: string;
7
+ version: string;
8
+ };
9
+ configs: {};
10
+ rules: {
11
+ 'copyright-text': _typescript_eslint_utils_ts_eslint0.RuleModule<"missingCopyright", [{
12
+ startYear?: number;
13
+ }], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
14
+ name: string;
15
+ };
16
+ };
17
+ };
18
+ //#endregion
19
+ export { plugin as default };
package/dist/index.mjs ADDED
@@ -0,0 +1,118 @@
1
+ import { AST_TOKEN_TYPES, ESLintUtils } from "@typescript-eslint/utils";
2
+
3
+ //#region src/constants/copyright.ts
4
+ const DEFAULT_START_YEAR = 2017;
5
+ const COPYRIGHT_TEXT = `
6
+ * Copyright {startYear}-{currentYear} Commencis. All Rights Reserved.
7
+ *
8
+ * Save to the extent permitted by law, you may not use, copy, modify,
9
+ * distribute or create derivative works of this material or any part
10
+ * of it without the prior written consent of Commencis.
11
+ * Any reproduction of this material must contain this notice.
12
+ `.trim();
13
+
14
+ //#endregion
15
+ //#region src/constants/docsBaseUrl.ts
16
+ const DOCS_BASE_URL = "https://github.com/Commencis/js-toolkit/tree/main/packages/eslint-plugin/docs/rules/";
17
+
18
+ //#endregion
19
+ //#region src/utils/getDocsUrl.ts
20
+ function getDocsUrls(ruleName) {
21
+ return `${DOCS_BASE_URL}${ruleName}.md`;
22
+ }
23
+
24
+ //#endregion
25
+ //#region src/utils/createRule.ts
26
+ const createRule = ESLintUtils.RuleCreator((name$1) => getDocsUrls(name$1));
27
+
28
+ //#endregion
29
+ //#region src/utils/getCopyrightText.ts
30
+ function getCopyrightText(startYear, isHtml) {
31
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
32
+ const formattedText = COPYRIGHT_TEXT.replace(/{startYear}/g, startYear.toString()).replace(/{currentYear}/g, currentYear.toString());
33
+ if (isHtml) return `<!--\n ${formattedText}\n-->`;
34
+ return `/*\n ${formattedText}\n */`;
35
+ }
36
+
37
+ //#endregion
38
+ //#region src/utils/validateCommencisCopyright.ts
39
+ function validateCommencisCopyright(comment) {
40
+ if (typeof comment === "string") return comment.includes("Commencis") && comment.includes("Copyright");
41
+ return !!comment && comment.type === AST_TOKEN_TYPES.Block && comment.value.includes("Commencis") && comment.value.includes("Copyright");
42
+ }
43
+
44
+ //#endregion
45
+ //#region src/rules/copyright-text.ts
46
+ var copyright_text_default = createRule({
47
+ name: "copyright-text",
48
+ meta: {
49
+ type: "suggestion",
50
+ docs: { description: "Ensure files start with the required Commencis copyright text" },
51
+ messages: { missingCopyright: "File must start with the required Commencis copyright text with correct dates." },
52
+ schema: [{
53
+ type: "object",
54
+ properties: { startYear: {
55
+ type: "number",
56
+ default: DEFAULT_START_YEAR
57
+ } },
58
+ additionalProperties: false
59
+ }],
60
+ fixable: "code"
61
+ },
62
+ defaultOptions: [{ startYear: DEFAULT_START_YEAR }],
63
+ create(context, [options]) {
64
+ const startYear = options.startYear ?? DEFAULT_START_YEAR;
65
+ const isHtml = context.filename.endsWith(".vue");
66
+ const expectedCopyrightText = getCopyrightText(startYear, isHtml);
67
+ return { Program(node) {
68
+ const sourceCode = context.sourceCode.getText();
69
+ const firstComment = context.sourceCode.getAllComments()[0];
70
+ const trimmedText = sourceCode.trimStart();
71
+ if (!trimmedText.startsWith(expectedCopyrightText)) {
72
+ const isCommencisCopyrightExists = validateCommencisCopyright(isHtml ? trimmedText : firstComment);
73
+ context.report({
74
+ node,
75
+ messageId: "missingCopyright",
76
+ fix(fixer) {
77
+ const insertText = `${expectedCopyrightText}\n\n`;
78
+ return isCommencisCopyrightExists ? isHtml ? fixer.replaceTextRange([0, insertText.length], insertText) : fixer.replaceText(firstComment, insertText) : fixer.insertTextBeforeRange([0, 0], insertText);
79
+ }
80
+ });
81
+ }
82
+ } };
83
+ }
84
+ });
85
+
86
+ //#endregion
87
+ //#region src/rules/index.ts
88
+ var rules_default = { "copyright-text": copyright_text_default };
89
+
90
+ //#endregion
91
+ //#region package.json
92
+ var name = "@commencis/eslint-plugin";
93
+ var version = "3.0.0";
94
+
95
+ //#endregion
96
+ //#region src/index.ts
97
+ const plugin = {
98
+ meta: {
99
+ name,
100
+ version
101
+ },
102
+ configs: {},
103
+ rules: rules_default
104
+ };
105
+ Object.assign(plugin.configs, {
106
+ all: [{
107
+ plugins: { "@commencis": plugin },
108
+ rules: { "@commencis/copyright-text": "error" }
109
+ }],
110
+ recommended: [{
111
+ plugins: { "@commencis": plugin },
112
+ rules: { "@commencis/copyright-text": "off" }
113
+ }]
114
+ });
115
+ var src_default = plugin;
116
+
117
+ //#endregion
118
+ export { src_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commencis/eslint-plugin",
3
- "version": "2.1.0",
3
+ "version": "3.0.0",
4
4
  "description": "Commencis ESLint plugin",
5
5
  "author": "Commencis WEB Team",
6
6
  "license": "Apache-2.0",
@@ -29,16 +29,14 @@
29
29
  "require": "./dist/index.cjs"
30
30
  },
31
31
  "dependencies": {
32
- "@typescript-eslint/utils": "8.49.0"
32
+ "@typescript-eslint/utils": "8.51.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@commencis/ts-config": "1.0.0",
36
- "tsup": "8.5.1",
37
- "typescript": "5.9.3"
35
+ "@commencis/ts-config": "1.0.0"
38
36
  },
39
37
  "scripts": {
40
- "dev": "tsup --watch",
41
- "build": "tsup",
38
+ "dev": "tsdown --watch",
39
+ "build": "tsdown",
42
40
  "lint:types": "tsc --noEmit"
43
41
  }
44
42
  }
package/dist/index.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
-
3
- declare const plugin: {
4
- meta: {
5
- name: string;
6
- version: string;
7
- };
8
- configs: {};
9
- rules: {
10
- 'copyright-text': _typescript_eslint_utils_ts_eslint.RuleModule<"missingCopyright", [{
11
- startYear?: number;
12
- }], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
13
- };
14
- };
15
-
16
- export { plugin as default };
package/dist/index.js DELETED
@@ -1,195 +0,0 @@
1
- // src/configs/all.ts
2
- var all = {
3
- "@commencis/copyright-text": "error"
4
- };
5
-
6
- // src/configs/recommended.ts
7
- var recommended = {
8
- "@commencis/copyright-text": "off"
9
- };
10
-
11
- // src/constants/copyright.ts
12
- var DEFAULT_START_YEAR = 2017;
13
- var COPYRIGHT_TEXT = `
14
- * Copyright {startYear}-{currentYear} Commencis. All Rights Reserved.
15
- *
16
- * Save to the extent permitted by law, you may not use, copy, modify,
17
- * distribute or create derivative works of this material or any part
18
- * of it without the prior written consent of Commencis.
19
- * Any reproduction of this material must contain this notice.
20
- `.trim();
21
-
22
- // src/constants/docsBaseUrl.ts
23
- var DOCS_BASE_URL = "https://github.com/Commencis/js-toolkit/tree/main/packages/eslint-plugin/docs/rules/";
24
-
25
- // src/utils/createRule.ts
26
- import { ESLintUtils } from "@typescript-eslint/utils";
27
-
28
- // src/utils/getDocsUrl.ts
29
- function getDocsUrls(ruleName) {
30
- return `${DOCS_BASE_URL}${ruleName}.md`;
31
- }
32
-
33
- // src/utils/createRule.ts
34
- var createRule = ESLintUtils.RuleCreator((name) => getDocsUrls(name));
35
-
36
- // src/utils/getCopyrightText.ts
37
- function getCopyrightText(startYear, isHtml) {
38
- const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
39
- const formattedText = COPYRIGHT_TEXT.replace(
40
- /{startYear}/g,
41
- startYear.toString()
42
- ).replace(/{currentYear}/g, currentYear.toString());
43
- if (isHtml) {
44
- return `<!--
45
- ${formattedText}
46
- -->`;
47
- }
48
- return `/*
49
- ${formattedText}
50
- */`;
51
- }
52
-
53
- // src/utils/validateCommencisCopyright.ts
54
- import { AST_TOKEN_TYPES } from "@typescript-eslint/utils";
55
- function validateCommencisCopyright(comment) {
56
- if (typeof comment === "string") {
57
- return comment.includes("Commencis") && comment.includes("Copyright");
58
- }
59
- return !!comment && comment.type === AST_TOKEN_TYPES.Block && comment.value.includes("Commencis") && comment.value.includes("Copyright");
60
- }
61
-
62
- // src/rules/copyright-text.ts
63
- var copyright_text_default = createRule({
64
- name: "copyright-text",
65
- meta: {
66
- type: "suggestion",
67
- docs: {
68
- description: "Ensure files start with the required Commencis copyright text"
69
- },
70
- messages: {
71
- missingCopyright: "File must start with the required Commencis copyright text with correct dates."
72
- },
73
- schema: [
74
- {
75
- type: "object",
76
- properties: {
77
- startYear: {
78
- type: "number",
79
- default: DEFAULT_START_YEAR
80
- }
81
- },
82
- additionalProperties: false
83
- }
84
- ],
85
- fixable: "code"
86
- },
87
- defaultOptions: [{ startYear: DEFAULT_START_YEAR }],
88
- create(context, [options]) {
89
- const startYear = options.startYear ?? DEFAULT_START_YEAR;
90
- const isHtml = context.filename.endsWith(".vue");
91
- const expectedCopyrightText = getCopyrightText(startYear, isHtml);
92
- return {
93
- Program(node) {
94
- const sourceCode = context.sourceCode.getText();
95
- const firstComment = context.sourceCode.getAllComments()[0];
96
- const trimmedText = sourceCode.trimStart();
97
- const isCopyrightValid = trimmedText.startsWith(expectedCopyrightText);
98
- if (!isCopyrightValid) {
99
- const isCommencisCopyrightExists = validateCommencisCopyright(
100
- isHtml ? trimmedText : firstComment
101
- );
102
- context.report({
103
- node,
104
- messageId: "missingCopyright",
105
- fix(fixer) {
106
- const insertText = `${expectedCopyrightText}
107
-
108
- `;
109
- return isCommencisCopyrightExists ? isHtml ? fixer.replaceTextRange([0, insertText.length], insertText) : fixer.replaceText(firstComment, insertText) : fixer.insertTextBeforeRange([0, 0], insertText);
110
- }
111
- });
112
- }
113
- }
114
- };
115
- }
116
- });
117
-
118
- // src/rules/index.ts
119
- var rules_default = {
120
- "copyright-text": copyright_text_default
121
- };
122
-
123
- // package.json
124
- var package_default = {
125
- name: "@commencis/eslint-plugin",
126
- version: "2.1.0",
127
- description: "Commencis ESLint plugin",
128
- author: "Commencis WEB Team",
129
- license: "Apache-2.0",
130
- type: "module",
131
- homepage: "https://github.com/Commencis/js-toolkit/tree/main/packages/eslint-plugin#readme",
132
- bugs: {
133
- url: "https://github.com/Commencis/js-toolkit/issues"
134
- },
135
- repository: {
136
- type: "git",
137
- url: "https://github.com/Commencis/js-toolkit.git",
138
- directory: "packages/eslint-plugin"
139
- },
140
- publishConfig: {
141
- access: "public"
142
- },
143
- main: "dist/index.js",
144
- files: [
145
- "dist",
146
- "*.md",
147
- "LICENSE"
148
- ],
149
- exports: {
150
- types: "./dist/index.d.ts",
151
- import: "./dist/index.js",
152
- require: "./dist/index.cjs"
153
- },
154
- scripts: {
155
- dev: "tsup --watch",
156
- build: "tsup",
157
- "lint:types": "tsc --noEmit"
158
- },
159
- dependencies: {
160
- "@typescript-eslint/utils": "8.49.0"
161
- },
162
- devDependencies: {
163
- "@commencis/ts-config": "1.0.0",
164
- tsup: "8.5.1",
165
- typescript: "5.9.3"
166
- }
167
- };
168
-
169
- // src/index.ts
170
- var plugin = {
171
- meta: {
172
- name: package_default.name,
173
- version: package_default.version
174
- },
175
- configs: {},
176
- rules: rules_default
177
- };
178
- Object.assign(plugin.configs, {
179
- all: [
180
- {
181
- plugins: { "@commencis": plugin },
182
- rules: all
183
- }
184
- ],
185
- recommended: [
186
- {
187
- plugins: { "@commencis": plugin },
188
- rules: recommended
189
- }
190
- ]
191
- });
192
- var index_default = plugin;
193
- export {
194
- index_default as default
195
- };