@salesforce-ux/eslint-plugin-slds 0.1.1 → 0.1.2
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/build/rules/bem-mapping.d.ts +1166 -1166
- package/build/rules/bem-mapping.js +1166 -1166
- package/build/rules/enforce-bem-class.d.ts +0 -1
- package/build/rules/enforce-bem-class.js +2 -5
- package/build/rules/utils/node.js +13 -14
- package/package.json +1 -1
|
@@ -20,13 +20,10 @@ module.exports = {
|
|
|
20
20
|
},
|
|
21
21
|
],
|
|
22
22
|
messages: {
|
|
23
|
-
errorMsg: "The {{actual}} class doesn’t follow the correct BEM naming convention.",
|
|
24
23
|
suggestedMsg: "{{actual}} has been retired. Update it to the new name {{newValue}}.",
|
|
25
24
|
},
|
|
26
25
|
},
|
|
27
26
|
create(context) {
|
|
28
|
-
const pattern = /^(?:[a-z0-9]+(?:-[a-z0-9]+)*)(__[a-z0-9]+(?:-[a-z0-9]+)*)?(--[a-z0-9]+(?:-[a-z0-9]+)*)?$/;
|
|
29
|
-
const checkNaming = (name) => pattern.test(name);
|
|
30
27
|
function check(node) {
|
|
31
28
|
if ((0, node_1.isAttributesEmpty)(node)) {
|
|
32
29
|
return;
|
|
@@ -35,7 +32,7 @@ module.exports = {
|
|
|
35
32
|
if (classAttr && classAttr.value) {
|
|
36
33
|
const classNames = classAttr.value.value.split(/\s+/);
|
|
37
34
|
classNames.forEach((className) => {
|
|
38
|
-
if (className &&
|
|
35
|
+
if (className && className in bem_mapping_1.bemMapping) {
|
|
39
36
|
// Find the exact location of the problematic class name
|
|
40
37
|
const classNameStart = classAttr.value.value.indexOf(className) + 7; // 7 here is for `class= "`
|
|
41
38
|
const classNameEnd = classNameStart + className.length;
|
|
@@ -57,7 +54,7 @@ module.exports = {
|
|
|
57
54
|
actual: className,
|
|
58
55
|
newValue
|
|
59
56
|
},
|
|
60
|
-
messageId:
|
|
57
|
+
messageId: "suggestedMsg",
|
|
61
58
|
fix(fixer) {
|
|
62
59
|
if (newValue) {
|
|
63
60
|
const newClassValue = classAttr.value.value.replace(className, newValue);
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// THIS IS TAKEN FROM html-eslint
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.findAttr = findAttr;
|
|
5
|
+
exports.isAttributesEmpty = isAttributesEmpty;
|
|
6
|
+
exports.isNodeTokensOnSameLine = isNodeTokensOnSameLine;
|
|
7
|
+
exports.splitToLineNodes = splitToLineNodes;
|
|
8
|
+
exports.getLocBetween = getLocBetween;
|
|
9
|
+
exports.isExpressionInTemplate = isExpressionInTemplate;
|
|
10
|
+
exports.isTag = isTag;
|
|
11
|
+
exports.isComment = isComment;
|
|
12
|
+
exports.isText = isText;
|
|
13
|
+
exports.isOverlapWithTemplates = isOverlapWithTemplates;
|
|
14
|
+
exports.codeToLines = codeToLines;
|
|
15
|
+
exports.isRangesOverlap = isRangesOverlap;
|
|
16
|
+
exports.getTemplateTokens = getTemplateTokens;
|
|
5
17
|
const parser_1 = require("@html-eslint/parser");
|
|
6
18
|
/**
|
|
7
19
|
* @param {TagNode | ScriptTagNode | StyleTagNode} node
|
|
@@ -11,7 +23,6 @@ const parser_1 = require("@html-eslint/parser");
|
|
|
11
23
|
function findAttr(node, key) {
|
|
12
24
|
return node.attributes.find((attr) => attr.key && attr.key.value.toLowerCase() === key.toLowerCase());
|
|
13
25
|
}
|
|
14
|
-
exports.findAttr = findAttr;
|
|
15
26
|
/**
|
|
16
27
|
* Checks whether a node's attributes is empty or not.
|
|
17
28
|
* @param {TagNode | ScriptTagNode | StyleTagNode} node
|
|
@@ -20,7 +31,6 @@ exports.findAttr = findAttr;
|
|
|
20
31
|
function isAttributesEmpty(node) {
|
|
21
32
|
return !node.attributes || node.attributes.length <= 0;
|
|
22
33
|
}
|
|
23
|
-
exports.isAttributesEmpty = isAttributesEmpty;
|
|
24
34
|
/**
|
|
25
35
|
* Checks whether a node's all tokens are on the same line or not.
|
|
26
36
|
* @param {AnyNode} node A node to check
|
|
@@ -29,7 +39,6 @@ exports.isAttributesEmpty = isAttributesEmpty;
|
|
|
29
39
|
function isNodeTokensOnSameLine(node) {
|
|
30
40
|
return node.loc.start.line === node.loc.end.line;
|
|
31
41
|
}
|
|
32
|
-
exports.isNodeTokensOnSameLine = isNodeTokensOnSameLine;
|
|
33
42
|
/**
|
|
34
43
|
*
|
|
35
44
|
* @param {Range} rangeA
|
|
@@ -39,7 +48,6 @@ exports.isNodeTokensOnSameLine = isNodeTokensOnSameLine;
|
|
|
39
48
|
function isRangesOverlap(rangeA, rangeB) {
|
|
40
49
|
return rangeA[0] < rangeB[1] && rangeB[0] < rangeA[1];
|
|
41
50
|
}
|
|
42
|
-
exports.isRangesOverlap = isRangesOverlap;
|
|
43
51
|
/**
|
|
44
52
|
* @param {(TextNode | CommentContentNode)['templates']} templates
|
|
45
53
|
* @param {Range} range
|
|
@@ -50,7 +58,6 @@ function isOverlapWithTemplates(templates, range) {
|
|
|
50
58
|
.filter((template) => template.isTemplate)
|
|
51
59
|
.some((template) => isRangesOverlap(template.range, range));
|
|
52
60
|
}
|
|
53
|
-
exports.isOverlapWithTemplates = isOverlapWithTemplates;
|
|
54
61
|
/**
|
|
55
62
|
*
|
|
56
63
|
* @param {TextNode | CommentContentNode} node
|
|
@@ -123,7 +130,6 @@ function splitToLineNodes(node) {
|
|
|
123
130
|
});
|
|
124
131
|
return lineNodes;
|
|
125
132
|
}
|
|
126
|
-
exports.splitToLineNodes = splitToLineNodes;
|
|
127
133
|
/**
|
|
128
134
|
* Get location between two nodes.
|
|
129
135
|
* @param {BaseNode} before A node placed in before
|
|
@@ -136,7 +142,6 @@ function getLocBetween(before, after) {
|
|
|
136
142
|
end: after.loc.start,
|
|
137
143
|
};
|
|
138
144
|
}
|
|
139
|
-
exports.getLocBetween = getLocBetween;
|
|
140
145
|
/**
|
|
141
146
|
* @param {AttributeValueNode} node
|
|
142
147
|
* @return {boolean}
|
|
@@ -147,7 +152,6 @@ function isExpressionInTemplate(node) {
|
|
|
147
152
|
}
|
|
148
153
|
return false;
|
|
149
154
|
}
|
|
150
|
-
exports.isExpressionInTemplate = isExpressionInTemplate;
|
|
151
155
|
/**
|
|
152
156
|
* @param {AnyNode} node
|
|
153
157
|
* @returns {node is TagNode}
|
|
@@ -155,7 +159,6 @@ exports.isExpressionInTemplate = isExpressionInTemplate;
|
|
|
155
159
|
function isTag(node) {
|
|
156
160
|
return node.type === parser_1.NODE_TYPES.Tag;
|
|
157
161
|
}
|
|
158
|
-
exports.isTag = isTag;
|
|
159
162
|
/**
|
|
160
163
|
* @param {AnyNode} node
|
|
161
164
|
* @returns {node is CommentNode}
|
|
@@ -163,7 +166,6 @@ exports.isTag = isTag;
|
|
|
163
166
|
function isComment(node) {
|
|
164
167
|
return node.type === parser_1.NODE_TYPES.Comment;
|
|
165
168
|
}
|
|
166
|
-
exports.isComment = isComment;
|
|
167
169
|
/**
|
|
168
170
|
* @param {AnyNode} node
|
|
169
171
|
* @returns {node is TextNode}
|
|
@@ -171,7 +173,6 @@ exports.isComment = isComment;
|
|
|
171
173
|
function isText(node) {
|
|
172
174
|
return node.type === parser_1.NODE_TYPES.Text;
|
|
173
175
|
}
|
|
174
|
-
exports.isText = isText;
|
|
175
176
|
const lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u;
|
|
176
177
|
const lineEndingPattern = new RegExp(lineBreakPattern.source, "gu");
|
|
177
178
|
/**
|
|
@@ -181,7 +182,6 @@ const lineEndingPattern = new RegExp(lineBreakPattern.source, "gu");
|
|
|
181
182
|
function codeToLines(source) {
|
|
182
183
|
return source.split(lineEndingPattern);
|
|
183
184
|
}
|
|
184
|
-
exports.codeToLines = codeToLines;
|
|
185
185
|
/**
|
|
186
186
|
*
|
|
187
187
|
* @param {AnyToken[]} tokens
|
|
@@ -195,4 +195,3 @@ function getTemplateTokens(tokens) {
|
|
|
195
195
|
// @ts-ignore
|
|
196
196
|
.filter((token) => token.isTemplate));
|
|
197
197
|
}
|
|
198
|
-
exports.getTemplateTokens = getTemplateTokens;
|