@evanpurkhiser/oxc-config 0.20.0 → 0.21.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@evanpurkhiser/oxc-config",
4
- "version": "0.20.0",
4
+ "version": "0.21.0",
5
5
  "description": "Evan Purkhiser's personal Oxc configuration",
6
6
  "license": "MIT",
7
7
  "author": "Evan Purkhiser <oxc-config.js@evanpurkhiser.com>",
package/src/common.mjs CHANGED
@@ -15,12 +15,13 @@ const common = {
15
15
  jsPlugins: [
16
16
  {
17
17
  name: 'oxc-config',
18
- specifier: fileURLToPath(new URL('./oxlint/comments.mjs', import.meta.url)),
18
+ specifier: fileURLToPath(new URL('./oxlint/plugin.mjs', import.meta.url)),
19
19
  },
20
20
  ],
21
21
 
22
22
  rules: {
23
23
  'oxc-config/multiline-jsdoc': ['error'],
24
+ 'oxc-config/no-multiline-nested-call': ['error'],
24
25
 
25
26
  // Best practices
26
27
  'array-callback-return': ['warn'],
@@ -30,6 +31,7 @@ const common = {
30
31
  'no-extra-label': ['error'],
31
32
  'no-implied-eval': ['error'],
32
33
  'no-lone-blocks': ['error'],
34
+ 'no-lonely-if': ['error'],
33
35
  'no-self-compare': ['error'],
34
36
  'no-sequences': ['error'],
35
37
  'no-useless-call': ['warn'],
@@ -80,6 +82,7 @@ const common = {
80
82
  'typescript/no-useless-constructor': ['error'],
81
83
  'typescript/array-type': ['error', {default: 'array-simple'}],
82
84
  'typescript/consistent-type-imports': ['error'],
85
+ 'typescript/consistent-type-definitions': ['error', 'interface'],
83
86
  'typescript/no-import-type-side-effects': ['error'],
84
87
  'typescript/no-non-null-asserted-optional-chain': ['error'],
85
88
  'typescript/no-non-null-asserted-nullish-coalescing': ['error'],
@@ -0,0 +1,29 @@
1
+ export default {
2
+ meta: {
3
+ messages: {
4
+ extractCall: 'Assign the multiline call result to a variable before passing it.',
5
+ },
6
+ },
7
+ create(context) {
8
+ return {
9
+ CallExpression(node) {
10
+ if (node.arguments.length !== 1) {
11
+ return;
12
+ }
13
+
14
+ const [argument] = node.arguments;
15
+ const expression =
16
+ argument.type === 'ChainExpression' ? argument.expression : argument;
17
+
18
+ if (
19
+ expression.type !== 'CallExpression' ||
20
+ argument.loc.start.line === argument.loc.end.line
21
+ ) {
22
+ return;
23
+ }
24
+
25
+ context.report({node: argument, messageId: 'extractCall'});
26
+ },
27
+ };
28
+ },
29
+ };
@@ -0,0 +1,9 @@
1
+ import comments from './comments.mjs';
2
+ import noMultilineNestedCall from './no-multiline-nested-call.mjs';
3
+
4
+ export default {
5
+ rules: {
6
+ ...comments.rules,
7
+ 'no-multiline-nested-call': noMultilineNestedCall,
8
+ },
9
+ };
@@ -0,0 +1,38 @@
1
+ import {RuleTester} from 'oxlint/plugins-dev';
2
+
3
+ import {describe, it} from 'node:test';
4
+
5
+ import plugin from '../src/oxlint/plugin.mjs';
6
+
7
+ RuleTester.describe = describe;
8
+ RuleTester.it = it;
9
+
10
+ const ruleName = 'no-multiline-nested-call';
11
+ const tester = new RuleTester({languageOptions: {parserOptions: {lang: 'ts'}}});
12
+
13
+ tester.run(ruleName, plugin.rules[ruleName], {
14
+ valid: [
15
+ 'send();',
16
+ 'send(\n format(value),\n);',
17
+ 'send({\n value,\n});',
18
+ 'items.map(item => {\n return format(item);\n});',
19
+ 'send(topic, format({\n value,\n}));',
20
+ 'send(...format({\n value,\n}));',
21
+ 'send(format?.({\n value,\n}).text);',
22
+ 'const message = format({\n value,\n});\nsend(message);',
23
+ ],
24
+ invalid: [
25
+ {
26
+ code: 'await send(\n helper.format({\n value,\n }),\n);',
27
+ errors: [{messageId: 'extractCall', line: 2, column: 2, endLine: 4, endColumn: 4}],
28
+ },
29
+ {
30
+ code: 'send(format<string>(\r\n value,\r\n));',
31
+ errors: [{messageId: 'extractCall'}],
32
+ },
33
+ {
34
+ code: 'send?.(helper.format?.({\n value,\n}));',
35
+ errors: [{messageId: 'extractCall'}],
36
+ },
37
+ ],
38
+ });