eslint-plugin-crisp 1.7.20 → 1.7.21

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 CHANGED
@@ -116,7 +116,7 @@ Each item has emojis denoting:
116
116
  | [semi-spacing](https://eslint.org/docs/latest/rules/semi-spacing) | Disallows space before semicolons, enforces spaces after | | 🟢 | 🟣 |
117
117
  | [space-before-blocks](https://eslint.org/docs/latest/rules/space-before-blocks) | Enforces consistent spacing before blocks | 🟠 | 🟢 | 🟣 |
118
118
  | [space-in-parens](https://eslint.org/docs/latest/rules/space-in-parens) | Enforces zero spaces inside of parentheses | 🟠 | 🟢 | 🟣 |
119
- | [space-infix-ops](https://eslint.org/docs/latest/rules/space-infix-ops) | Enforces spaces around infix operators | | 🟢 | 🟣 |
119
+ | [space-infix-ops](https://eslint.org/docs/latest/rules/space-infix-ops) | Enforces spaces around infix operators | 🟠 | 🟢 | 🟣 |
120
120
 
121
121
  #### Crisp JS rules
122
122
 
@@ -141,7 +141,6 @@ Each item has emojis denoting:
141
141
  | [crisp/no-extra-line-within-function](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-extra-line-within-function.js) | Allows at most one empty line between declarations within functions | 🟠 | 🟢 | 🟣 |
142
142
  | [crisp/no-inline-function-in-ternary](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-inline-function-in-ternary.js) | Disallows inline functions in ternary branches | 🟠 | 🟢 | 🟣 |
143
143
  | [crisp/no-short-parameters](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-short-parameters.js) | Disallows one-character parameter names | 🟠 | 🟢 | 🟣 |
144
- | [crisp/no-space-in-default-parameters](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-space-in-default-parameters.js) | Disallows space before or after `=` in default parameters | 🟠 |
145
144
  | [crisp/no-snake-case](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-snake-case.js) | Disallows snake_case | | 🟢 | 🟣 |
146
145
  | [crisp/no-useless-template-literals](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-useless-template-literals.js) | Disallows unnecessary use of template literals | | 🟢 | 🟣 |
147
146
  | [crisp/no-var-in-blocks](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-var-in-blocks.js) | Disallows `var` declarations inside function, method, or class block | 🟠 | 🟢 | 🟣 |
package/index.js CHANGED
@@ -29,7 +29,6 @@ import ruleNewlineAfterSwitchCase from "./rules/newline-after-switch-case.js";
29
29
  import ruleNoAsync from "./rules/no-async.js";
30
30
  import ruleNoExtraLineWithinFunction from "./rules/no-extra-line-within-function.js";
31
31
  import ruleNoInlineFunctionInTernary from "./rules/no-inline-function-in-ternary.js";
32
- import ruleNoSpaceInDefaultParameters from "./rules/no-space-in-default-parameters.js";
33
32
  import ruleNoUselessTemplateLiterals from "./rules/no-useless-template-literals.js";
34
33
  import ruleNoVarInBlocks from "./rules/no-var-in-blocks.js";
35
34
  import ruleNoShortParameters from "./rules/no-short-parameters.js";
@@ -107,7 +106,6 @@ const plugin = {
107
106
  "no-async": ruleNoAsync,
108
107
  "no-extra-line-within-function": ruleNoExtraLineWithinFunction,
109
108
  "no-inline-function-in-ternary": ruleNoInlineFunctionInTernary,
110
- "no-space-in-default-parameters": ruleNoSpaceInDefaultParameters,
111
109
  "no-var-in-blocks": ruleNoVarInBlocks,
112
110
  "no-useless-template-literals": ruleNoUselessTemplateLiterals,
113
111
  "no-short-parameters": ruleNoShortParameters,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-crisp",
3
- "version": "1.7.20",
3
+ "version": "1.7.21",
4
4
  "description": "Custom ESLint Rules for Crisp",
5
5
  "author": "Crisp IM SAS",
6
6
  "main": "index.js",
package/recommended.js CHANGED
@@ -153,6 +153,7 @@ export default function configRecommended(pluginCrisp) {
153
153
  "semi-style": ["error", "last"],
154
154
  "space-before-blocks": "error",
155
155
  "space-in-parens": ["error", "never"],
156
+ "space-infix-ops": "error",
156
157
 
157
158
  // Crisp JS rules
158
159
  "crisp/align-comments": "error",
@@ -179,7 +180,6 @@ export default function configRecommended(pluginCrisp) {
179
180
  "exceptions": ["_", "$"]
180
181
  }
181
182
  ],
182
- "crisp/no-space-in-default-parameters": "error",
183
183
  "crisp/one-space-after-operator": [
184
184
  "error",
185
185
 
@@ -20,6 +20,19 @@ test("all recommended configs reject multiple spaces", () => {
20
20
  }
21
21
  });
22
22
 
23
+ test("recommended config uses standard default parameter spacing", () => {
24
+ const result = new Linter().verifyAndFix(
25
+ "function greet(name=\"World\") {}",
26
+ [{
27
+ rules: {
28
+ "space-infix-ops": recommendedRules["space-infix-ops"]
29
+ }
30
+ }]
31
+ );
32
+
33
+ assert.equal(result.output, "function greet(name = \"World\") {}");
34
+ });
35
+
23
36
  test("recommended config removes legacy assignment alignment", () => {
24
37
  const input = `class Example {
25
38
  constructor() {
@@ -1,24 +0,0 @@
1
- export default {
2
- create: function(context) {
3
- return {
4
- "FunctionDeclaration, FunctionExpression, ArrowFunctionExpression, MethodDefinition": function(node) {
5
- (node.params || []).forEach(param => {
6
- if (param.type === "AssignmentPattern") {
7
- const sourceCode = context.sourceCode;
8
- const operatorToken = sourceCode.getFirstTokenBetween(param.left, param.right, token => token.value === "=");
9
-
10
- if (
11
- sourceCode.getTokenBefore(operatorToken).range[1] !== operatorToken.range[0] ||
12
- sourceCode.getTokenAfter(operatorToken).range[0] !== operatorToken.range[1]
13
- ) {
14
- context.report({
15
- node,
16
- message: "There should be no space before or after = in default parameters"
17
- });
18
- }
19
- }
20
- });
21
- }
22
- };
23
- }
24
- };
@@ -1,40 +0,0 @@
1
- import rule from "../../rules/no-space-in-default-parameters.js";
2
- import createRuleTester from "../rule-tester.js";
3
-
4
- const ruleTester = createRuleTester();
5
-
6
- ruleTester.run("no-space-in-default-parameters", rule, {
7
- valid: [
8
- "function greet(name=\"World\") {}",
9
- "const greet = (name=\"World\") => name;",
10
- "const object = { greet(name=\"World\") {} };",
11
- "function required(name) {}"
12
- ],
13
-
14
- invalid: [
15
- {
16
- code: "function greet(name =\"World\") {}",
17
- errors: [
18
- {
19
- message: "There should be no space before or after = in default parameters"
20
- }
21
- ]
22
- },
23
- {
24
- code: "const greet = (name= \"World\") => name;",
25
- errors: [
26
- {
27
- message: "There should be no space before or after = in default parameters"
28
- }
29
- ]
30
- },
31
- {
32
- code: "class Greeter { greet(name = \"World\") {} }",
33
- errors: [
34
- {
35
- message: "There should be no space before or after = in default parameters"
36
- }
37
- ]
38
- }
39
- ]
40
- });