eslint-plugin-crisp 1.7.21 → 1.7.22
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/README.md +1 -0
- package/package.json +1 -1
- package/recommended-ts.js +1 -0
- package/recommended-vue.js +1 -0
- package/recommended.js +1 -0
- package/tests/recommended.test.js +34 -0
package/README.md
CHANGED
|
@@ -105,6 +105,7 @@ Each item has emojis denoting:
|
|
|
105
105
|
| [no-unsafe-optional-chaining](https://eslint.org/docs/latest/rules/no-unsafe-optional-chaining) | Disallows use of optional chaining in contexts where the `undefined` value is not allowed | 🟠 | 🟢 | 🟣 |
|
|
106
106
|
| [object-curly-newline](https://eslint.org/docs/latest/rules/object-curly-newline) | Requires line breaks after opening and before closing braces | 🟠 | 🟢 | 🟣 |
|
|
107
107
|
| [object-curly-spacing](https://eslint.org/docs/latest/rules/object-curly-spacing) | Requires spacing inside of braces | 🟠 | 🟢 | 🟣 |
|
|
108
|
+
| [object-shorthand](https://eslint.org/docs/latest/rules/object-shorthand) | Disallows shorthand properties and methods in object literals, requiring explicit keys and values even when their names match | 🟠 | 🟢 | 🟣 |
|
|
108
109
|
| [padded-blocks](https://eslint.org/docs/latest/rules/padded-blocks) | Disallows empty lines at the beginning and ending of blocks | 🟠 | 🟢 | 🟣 |
|
|
109
110
|
| [padding-line-between-statements](https://eslint.org/docs/latest/rules/padding-line-between-statements) | Requires padding lines between various statements | 🟠 | 🟢 | 🟣 |
|
|
110
111
|
| [prefer-arrow-callback](https://eslint.org/docs/latest/rules/prefer-arrow-callback) | Requires using arrow functions for callbacks | | 🟢 | 🟣 |
|
package/package.json
CHANGED
package/recommended-ts.js
CHANGED
|
@@ -119,6 +119,7 @@ export default function configRecommendedTS(pluginCrisp) {
|
|
|
119
119
|
}
|
|
120
120
|
],
|
|
121
121
|
"object-curly-spacing": ["error", "always"],
|
|
122
|
+
"object-shorthand": ["error", "never"],
|
|
122
123
|
"padded-blocks": ["error", "never"],
|
|
123
124
|
"padding-line-between-statements": [
|
|
124
125
|
"error",
|
package/recommended-vue.js
CHANGED
|
@@ -126,6 +126,7 @@ export default function configRecommendedVue(pluginCrisp) {
|
|
|
126
126
|
}
|
|
127
127
|
],
|
|
128
128
|
"object-curly-spacing": ["error", "always"],
|
|
129
|
+
"object-shorthand": ["error", "never"],
|
|
129
130
|
"padded-blocks": ["error", "never"],
|
|
130
131
|
"padding-line-between-statements": [
|
|
131
132
|
"error",
|
package/recommended.js
CHANGED
|
@@ -123,6 +123,7 @@ export default function configRecommended(pluginCrisp) {
|
|
|
123
123
|
}
|
|
124
124
|
],
|
|
125
125
|
"object-curly-spacing": ["error", "always"],
|
|
126
|
+
"object-shorthand": ["error", "never"],
|
|
126
127
|
"padded-blocks": ["error", "never"],
|
|
127
128
|
"padding-line-between-statements": [
|
|
128
129
|
"error",
|
|
@@ -20,6 +20,40 @@ test("all recommended configs reject multiple spaces", () => {
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
test("all recommended configs reject and expand object shorthand", () => {
|
|
24
|
+
for (const configName of [
|
|
25
|
+
"recommended",
|
|
26
|
+
"recommended-vue",
|
|
27
|
+
"recommended-ts"
|
|
28
|
+
]) {
|
|
29
|
+
const rules = plugin.configs[configName].find(
|
|
30
|
+
config => config.rules?.["object-shorthand"]
|
|
31
|
+
)?.rules;
|
|
32
|
+
|
|
33
|
+
assert.deepEqual(rules?.["object-shorthand"], ["error", "never"]);
|
|
34
|
+
|
|
35
|
+
const linter = new Linter();
|
|
36
|
+
const config = [{
|
|
37
|
+
rules: {
|
|
38
|
+
"object-shorthand": rules["object-shorthand"]
|
|
39
|
+
}
|
|
40
|
+
}];
|
|
41
|
+
const input = "const value = 1; const object = { value, method() {} };";
|
|
42
|
+
const messages = linter.verify(input, config);
|
|
43
|
+
|
|
44
|
+
assert.equal(messages.length, 2);
|
|
45
|
+
assert.ok(messages.every(message => message.ruleId === "object-shorthand"));
|
|
46
|
+
|
|
47
|
+
const result = linter.verifyAndFix(input, config);
|
|
48
|
+
|
|
49
|
+
assert.equal(
|
|
50
|
+
result.output,
|
|
51
|
+
"const value = 1; const object = { value: value, method: function() {} };"
|
|
52
|
+
);
|
|
53
|
+
assert.deepEqual(result.messages, []);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
23
57
|
test("recommended config uses standard default parameter spacing", () => {
|
|
24
58
|
const result = new Linter().verifyAndFix(
|
|
25
59
|
"function greet(name=\"World\") {}",
|