Skip to content

Commit ceb876a

Browse files
authored
Merge branch 'main' into fix/csharp-enum
2 parents b418fed + dc252ae commit ceb876a

27 files changed

+744
-3508
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ jobs:
204204
cd clients/algoliasearch-client-javascript/packages
205205
ls | grep -v -E "(client-common|requester-*|algoliasearch)" | xargs rm -rf
206206
cd algoliasearch
207-
ls | grep -v -E "(__tests__|jest.config.ts)" | xargs rm -rf
207+
ls | grep -v -E "__tests__" | xargs rm -rf
208208
209209
- name: Setup
210210
uses: ./.github/actions/setup

eslint/babel.config.cjs

Lines changed: 0 additions & 13 deletions
This file was deleted.

eslint/jest.config.cjs

Lines changed: 0 additions & 7 deletions
This file was deleted.

eslint/package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,25 @@
22
"name": "eslint-plugin-automation-custom",
33
"version": "1.0.0",
44
"description": "Custom rules for eslint",
5-
"main": "dist/index.js",
5+
"type": "module",
6+
"main": "dist/index.cjs",
67
"files": [
78
"src/**.ts"
89
],
910
"scripts": {
10-
"build": "esbuild --bundle --minify --platform=node --outdir=dist --log-level=error src/index.ts",
11+
"build": "esbuild --bundle --minify --platform=node --outdir=dist --out-extension:.js=.cjs --log-level=error src/index.ts",
1112
"lint": "eslint --ext=ts .",
1213
"lint:fix": "eslint --ext=ts --fix .",
13-
"test": "jest"
14+
"test": "tsc --noEmit && vitest"
1415
},
1516
"devDependencies": {
16-
"@babel/core": "7.25.2",
17-
"@babel/preset-env": "7.25.4",
18-
"@babel/preset-typescript": "7.24.7",
19-
"@types/jest": "29.5.13",
17+
"@types/eslint": "9.6.1",
2018
"esbuild": "0.23.1",
2119
"eslint": "8.57.0",
22-
"jest": "29.7.0",
23-
"typescript": "5.6.2"
20+
"eslint-plugin-yml": "1.14.0",
21+
"eslint-vitest-rule-tester": "0.6.1",
22+
"typescript": "5.6.2",
23+
"vitest": "2.1.1",
24+
"yaml-eslint-parser": "1.2.3"
2425
}
2526
}

eslint/src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { endWithDot } from './rules/endWithDot';
2-
import { noFinalDot } from './rules/noFinalDot';
3-
import { noNewLine } from './rules/noNewLine';
4-
import { createOutOfLineRule } from './rules/outOfLineRule';
5-
import { refCommon } from './rules/refCommon';
6-
import { singleQuoteRef } from './rules/singleQuoteRef';
7-
import { validACL } from './rules/validACL';
8-
import { validInlineTitle } from './rules/validInlineTitle';
1+
import { endWithDot } from './rules/endWithDot.js';
2+
import { noFinalDot } from './rules/noFinalDot.js';
3+
import { noNewLine } from './rules/noNewLine.js';
4+
import { createOutOfLineRule } from './rules/outOfLineRule.js';
5+
import { refCommon } from './rules/refCommon.js';
6+
import { singleQuoteRef } from './rules/singleQuoteRef.js';
7+
import { validACL } from './rules/validACL.js';
8+
import { validInlineTitle } from './rules/validInlineTitle.js';
99

1010
const rules = {
1111
'end-with-dot': endWithDot,

eslint/src/rules/endWithDot.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
import type { Rule } from 'eslint';
1+
import { createRule } from 'eslint-plugin-yml/lib/utils';
22

3-
import { isBlockScalar, isPairWithKey, isScalar } from '../utils';
3+
import { isBlockScalar, isPairWithKey, isScalar } from '../utils.js';
44

5-
export const endWithDot: Rule.RuleModule = {
5+
export const endWithDot = createRule('endWithDot', {
66
meta: {
77
docs: {
88
description: '`description` must end with a period',
9+
categories: null,
10+
extensionRule: false,
11+
layout: false,
912
},
1013
messages: {
1114
endWithDot: 'description does not end with a period',
1215
},
1316
fixable: 'code',
17+
type: 'layout',
18+
schema: [],
1419
},
1520
create(context) {
16-
if (!context.sourceCode.parserServices.isYAML) {
21+
if (!context.getSourceCode().parserServices?.isYAML) {
1722
return {};
1823
}
1924

@@ -52,4 +57,4 @@ export const endWithDot: Rule.RuleModule = {
5257
},
5358
};
5459
},
55-
};
60+
});

eslint/src/rules/noFinalDot.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
import type { Rule } from 'eslint';
1+
import { createRule } from 'eslint-plugin-yml/lib/utils';
22

3-
import { isPairWithKey, isScalar } from '../utils';
3+
import { isPairWithKey, isScalar } from '../utils.js';
44

5-
export const noFinalDot: Rule.RuleModule = {
5+
export const noFinalDot = createRule('noFinalDot', {
66
meta: {
77
docs: {
88
description: '`summary` must not end with a period',
9+
categories: null,
10+
extensionRule: false,
11+
layout: false,
912
},
1013
messages: {
1114
noFinalDot: 'summary ends with a period',
1215
},
1316
fixable: 'code',
17+
type: 'layout',
18+
schema: [],
1419
},
1520
create(context) {
16-
if (!context.sourceCode.parserServices.isYAML) {
21+
if (!context.getSourceCode().parserServices.isYAML) {
1722
return {};
1823
}
1924

@@ -46,4 +51,4 @@ export const noFinalDot: Rule.RuleModule = {
4651
},
4752
};
4853
},
49-
};
54+
});

eslint/src/rules/outOfLineRule.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type { Rule } from 'eslint';
1+
import { RuleModule } from 'eslint-plugin-yml/lib/types.js';
2+
import { createRule } from 'eslint-plugin-yml/lib/utils';
23

3-
import { isNullable, isPairWithKey } from '../utils';
4+
import { isNullable, isPairWithKey } from '../utils.js';
45

56
export function createOutOfLineRule({
67
property,
@@ -12,18 +13,23 @@ export function createOutOfLineRule({
1213
description?: string;
1314
messageId?: string;
1415
message?: string;
15-
}): Rule.RuleModule {
16-
const rule: Rule.RuleModule = {
16+
}): RuleModule {
17+
return createRule(`${property}OutOfLine`, {
1718
meta: {
1819
docs: {
1920
description,
21+
categories: null,
22+
extensionRule: false,
23+
layout: false,
2024
},
2125
messages: {
2226
[messageId]: message,
2327
},
28+
type: 'layout',
29+
schema: [],
2430
},
2531
create(context) {
26-
if (!context.sourceCode.parserServices.isYAML) {
32+
if (!context.getSourceCode().parserServices.isYAML) {
2733
return {};
2834
}
2935

@@ -59,6 +65,5 @@ export function createOutOfLineRule({
5965
},
6066
};
6167
},
62-
};
63-
return rule;
68+
});
6469
}

eslint/src/rules/refCommon.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { Rule } from 'eslint';
1+
import { createRule } from 'eslint-plugin-yml/lib/utils';
22

3-
import { isPairWithKey, isScalar } from '../utils';
3+
import { isPairWithKey, isScalar } from '../utils.js';
44

55
const allSpecs = [
66
'abtesting',
@@ -15,18 +15,23 @@ const allSpecs = [
1515
'search',
1616
];
1717

18-
export const refCommon: Rule.RuleModule = {
18+
export const refCommon = createRule('refCommon', {
1919
meta: {
2020
docs: {
2121
description:
2222
'the $ref must target the current spec, or the common spec. If you intended to use a model from an other spec, move it to the common folder',
23+
categories: null,
24+
extensionRule: false,
25+
layout: false,
2326
},
2427
messages: {
2528
refCommon: '$ref to another spec',
2629
},
30+
type: 'layout',
31+
schema: [],
2732
},
2833
create(context) {
29-
if (!context.sourceCode.parserServices.isYAML) {
34+
if (!context.getSourceCode().parserServices.isYAML) {
3035
return {};
3136
}
3237

@@ -45,7 +50,7 @@ export const refCommon: Rule.RuleModule = {
4550
return;
4651
}
4752

48-
const spec = context.filename.match(/specs\/([a-z-]+?)\//)?.[1];
53+
const spec = context.getFilename().match(/specs\/([a-z-]+?)\//)?.[1];
4954
if (!spec) {
5055
return;
5156
}
@@ -63,4 +68,4 @@ export const refCommon: Rule.RuleModule = {
6368
},
6469
};
6570
},
66-
};
71+
});

eslint/src/rules/singleQuoteRef.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
import type { Rule } from 'eslint';
1+
import { createRule } from 'eslint-plugin-yml/lib/utils';
22

3-
import { isBlockScalar, isPairWithKey, isScalar } from '../utils';
3+
import { isBlockScalar, isPairWithKey, isScalar } from '../utils.js';
44

5-
export const singleQuoteRef: Rule.RuleModule = {
5+
export const singleQuoteRef = createRule('singleQuoteRef', {
66
meta: {
77
docs: {
88
description: '$ref must be wrapped in single quote',
9+
categories: null,
10+
extensionRule: false,
11+
layout: false,
912
},
1013
messages: {
1114
refNoQuote: '$ref is not wrapped in single quote',
1215
},
1316
fixable: 'code',
17+
type: 'layout',
18+
schema: [],
1419
},
1520
create(context) {
16-
if (!context.sourceCode.parserServices.isYAML) {
21+
if (!context.getSourceCode().parserServices.isYAML) {
1722
return {};
1823
}
1924

@@ -52,4 +57,4 @@ export const singleQuoteRef: Rule.RuleModule = {
5257
},
5358
};
5459
},
55-
};
60+
});

eslint/src/rules/validACL.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { Rule } from 'eslint';
1+
import { createRule } from 'eslint-plugin-yml/lib/utils';
22

3-
import { isPairWithKey, isScalar } from '../utils';
3+
import { isPairWithKey, isScalar } from '../utils.js';
44

55
const ACLs = [
66
'search',
@@ -19,19 +19,24 @@ const ACLs = [
1919
'admin',
2020
];
2121

22-
export const validACL: Rule.RuleModule = {
22+
export const validACL = createRule('validACL', {
2323
meta: {
2424
docs: {
2525
description: 'x-acl enum must contains valid Algolia ACLs',
26+
categories: null,
27+
extensionRule: false,
28+
layout: false,
2629
},
2730
messages: {
2831
validString: 'is not a string',
2932
validACL: `{{entry}} is not a valid Algolia ACL, must be one of: ${ACLs.join(', ')}.`,
3033
validArray: 'is not an array of string',
3134
},
35+
type: 'layout',
36+
schema: [],
3237
},
3338
create(context) {
34-
if (!context.sourceCode.parserServices.isYAML) {
39+
if (!context.getSourceCode().parserServices.isYAML) {
3540
return {};
3641
}
3742

@@ -75,4 +80,4 @@ export const validACL: Rule.RuleModule = {
7580
},
7681
};
7782
},
78-
};
83+
});

eslint/src/rules/validInlineTitle.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
import type { Rule } from 'eslint';
1+
import { createRule } from 'eslint-plugin-yml/lib/utils';
22

3-
import { isNullable, isPairWithKey } from '../utils';
3+
import { isNullable, isPairWithKey } from '../utils.js';
44

5-
export const validInlineTitle: Rule.RuleModule = {
5+
export const validInlineTitle = createRule('validInlineTitle', {
66
meta: {
77
docs: {
88
description: 'title must be set in inline models, should be the first property and start with a lowercase',
9+
categories: null,
10+
extensionRule: false,
11+
layout: false,
912
},
1013
messages: {
1114
inlineTitleExists: 'title must be set in inline models',
1215
lowercaseTitle: 'title must start with a lowercase',
1316
firstProperty: 'title must be the first property',
1417
noSpaceInTitle: 'title must not contain spaces',
1518
},
19+
type: 'layout',
20+
schema: [],
1621
},
1722
create(context) {
18-
if (!context.sourceCode.parserServices.isYAML) {
23+
if (!context.getSourceCode().parserServices.isYAML) {
1924
return {};
2025
}
2126

@@ -44,7 +49,7 @@ export const validInlineTitle: Rule.RuleModule = {
4449
// make sure title doesn't contain spaces
4550
if (titleValue?.includes(' ')) {
4651
context.report({
47-
node: title,
52+
node: title!,
4853
messageId: 'noSpaceInTitle',
4954
});
5055
}
@@ -85,4 +90,4 @@ export const validInlineTitle: Rule.RuleModule = {
8590
},
8691
};
8792
},
88-
};
93+
});

0 commit comments

Comments
 (0)