@commencis/eslint-plugin 1.3.0 → 1.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @commencis/eslint-plugin
2
2
 
3
+ ## 1.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: add vue support for copyright-text replacement ([#196](https://github.com/Commencis/js-toolkit/pull/196))
8
+
3
9
  ## 1.3.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -78,8 +78,11 @@ function getCopyrightText(startYear, isHtml) {
78
78
 
79
79
  // src/utils/validateCommencisCopyright.ts
80
80
  var import_utils2 = require("@typescript-eslint/utils");
81
- function validateCommencisCopyright(commentNode) {
82
- return !!commentNode && commentNode.type === import_utils2.AST_TOKEN_TYPES.Block && commentNode.value.includes("Commencis") && commentNode.value.includes("Copyright");
81
+ 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");
83
86
  }
84
87
 
85
88
  // src/rules/copyright-text.ts
@@ -119,7 +122,9 @@ var copyright_text_default = createRule({
119
122
  const trimmedText = sourceCode.trimStart();
120
123
  const isCopyrightValid = trimmedText.startsWith(expectedCopyrightText);
121
124
  if (!isCopyrightValid) {
122
- const isCommencisCopyrightExists = validateCommencisCopyright(firstComment);
125
+ const isCommencisCopyrightExists = validateCommencisCopyright(
126
+ isHtml ? trimmedText : firstComment
127
+ );
123
128
  context.report({
124
129
  node,
125
130
  messageId: "missingCopyright",
@@ -127,7 +132,7 @@ var copyright_text_default = createRule({
127
132
  const insertText = `${expectedCopyrightText}
128
133
 
129
134
  `;
130
- return isCommencisCopyrightExists ? fixer.replaceText(firstComment, insertText) : fixer.insertTextBeforeRange([0, 0], insertText);
135
+ return isCommencisCopyrightExists ? isHtml ? fixer.replaceTextRange([0, insertText.length], insertText) : fixer.replaceText(firstComment, insertText) : fixer.insertTextBeforeRange([0, 0], insertText);
131
136
  }
132
137
  });
133
138
  }
@@ -144,7 +149,7 @@ var rules_default = {
144
149
  // package.json
145
150
  var package_default = {
146
151
  name: "@commencis/eslint-plugin",
147
- version: "1.3.0",
152
+ version: "1.3.1",
148
153
  description: "Commencis ESLint plugin",
149
154
  author: "Commencis WEB Team",
150
155
  license: "Apache-2.0",
package/dist/index.js CHANGED
@@ -52,8 +52,11 @@ function getCopyrightText(startYear, isHtml) {
52
52
 
53
53
  // src/utils/validateCommencisCopyright.ts
54
54
  import { AST_TOKEN_TYPES } from "@typescript-eslint/utils";
55
- function validateCommencisCopyright(commentNode) {
56
- return !!commentNode && commentNode.type === AST_TOKEN_TYPES.Block && commentNode.value.includes("Commencis") && commentNode.value.includes("Copyright");
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");
57
60
  }
58
61
 
59
62
  // src/rules/copyright-text.ts
@@ -93,7 +96,9 @@ var copyright_text_default = createRule({
93
96
  const trimmedText = sourceCode.trimStart();
94
97
  const isCopyrightValid = trimmedText.startsWith(expectedCopyrightText);
95
98
  if (!isCopyrightValid) {
96
- const isCommencisCopyrightExists = validateCommencisCopyright(firstComment);
99
+ const isCommencisCopyrightExists = validateCommencisCopyright(
100
+ isHtml ? trimmedText : firstComment
101
+ );
97
102
  context.report({
98
103
  node,
99
104
  messageId: "missingCopyright",
@@ -101,7 +106,7 @@ var copyright_text_default = createRule({
101
106
  const insertText = `${expectedCopyrightText}
102
107
 
103
108
  `;
104
- return isCommencisCopyrightExists ? fixer.replaceText(firstComment, insertText) : fixer.insertTextBeforeRange([0, 0], insertText);
109
+ return isCommencisCopyrightExists ? isHtml ? fixer.replaceTextRange([0, insertText.length], insertText) : fixer.replaceText(firstComment, insertText) : fixer.insertTextBeforeRange([0, 0], insertText);
105
110
  }
106
111
  });
107
112
  }
@@ -118,7 +123,7 @@ var rules_default = {
118
123
  // package.json
119
124
  var package_default = {
120
125
  name: "@commencis/eslint-plugin",
121
- version: "1.3.0",
126
+ version: "1.3.1",
122
127
  description: "Commencis ESLint plugin",
123
128
  author: "Commencis WEB Team",
124
129
  license: "Apache-2.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commencis/eslint-plugin",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Commencis ESLint plugin",
5
5
  "author": "Commencis WEB Team",
6
6
  "license": "Apache-2.0",