Skip to content

Commit 6212ef7

Browse files
authored
(EAI-243): Lint space between entities (#383)
* Add lint script and rules * Add prettierrc.js to all packages * Update prettierrc * Update prettierrc * Run lint
1 parent 2b8757c commit 6212ef7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+184
-63
lines changed

.eslintrc.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
},
55
root: true,
66
parser: "@typescript-eslint/parser",
7-
plugins: ["@typescript-eslint", "jest", "jsdoc", "prettier"],
7+
plugins: ["@typescript-eslint", "jest", "jsdoc", "prettier", "@stylistic/js"],
88
extends: [
99
"eslint:recommended",
1010
"prettier",

.prettierrc.cjs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
embeddedLanguageFormatting: "off",
3+
};

examples/quick-start/packages/ui/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"scripts": {
66
"dev": "vite",
77
"build": "tsc && vite build",
8-
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
8+
"lint": "eslint ./src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
9+
"lint:fix": "npm run lint -- --fix && prettier ./src --check --write",
910
"preview": "vite preview"
1011
},
1112
"dependencies": {

package-lock.json

+43-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"build": "lerna run build",
1616
"test": "lerna run test",
1717
"lint": "lerna run lint",
18+
"lint:fix": "lerna run lint:fix",
1819
"release:chat-ui": "lerna run release --scope='mongodb-chatbot-ui' && git add ./package-lock.json && git commit --amend --no-edit",
1920
"scripts:analyzeMessages": "lerna run analyzeMessages --scope='scripts'",
2021
"scripts:scrubMessages": "lerna run scrubMessages --scope='scripts'",
@@ -26,6 +27,7 @@
2627
"eval:faqConversationQualityCheckPipeline": "lerna run pipeline:faqConversationQualityCheck --scope='chatbot-eval-mongodb-public'"
2728
},
2829
"devDependencies": {
30+
"@stylistic/eslint-plugin-js": "^1.7.0",
2931
"lerna": "^5.6.2"
3032
}
3133
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const baseConfig = require(`${__dirname}/../../.prettierrc.cjs`);
2+
3+
module.exports = {
4+
...baseConfig,
5+
};

packages/chatbot-eval-mongodb-public/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"watch": "tsc -b -w",
1616
"release": "release-it",
1717
"lint": "eslint ./src --ext ts --report-unused-disable-directives",
18+
"lint:fix": "npm run lint -- --fix && prettier ./src --check --write",
1819
"generate:conversations": "../mongodb-chatbot-eval/build/main.js generate --name conversations --config ./build/eval.config.js",
1920
"generate:faqConversations": "../mongodb-chatbot-eval/build/main.js generate --name faqConversations --config ./build/eval.config.js",
2021
"report:conversationQualityRun": "../mongodb-chatbot-eval/build/main.js report --name conversationQualityRun --config ./build/eval.config.js",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const baseConfig = require(`${__dirname}/../../.prettierrc.cjs`);
2+
3+
module.exports = {
4+
...baseConfig,
5+
};

packages/chatbot-server-mongodb-public/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"dev": "nodemon src/index.ts",
1919
"format": "prettier ./src --write",
2020
"format:check": "prettier ./src --check",
21-
"lint": "eslint ./src --ext js,jsx,ts,tsx --report-unused-disable-directives",
21+
"lint": "eslint ./src --ext ts,tsx,js,jsx --report-unused-disable-directives",
22+
"lint:fix": "npm run lint -- --fix && prettier ./src --check --write",
2223
"start": "pm2-runtime ./build/index.js",
2324
"test": "jest --forceExit",
2425
"release": "release-it"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const baseConfig = require(`${__dirname}/../../.prettierrc.cjs`);
2+
3+
module.exports = {
4+
...baseConfig,
5+
};

packages/ingest-mongodb-public/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"watch": "tsc -b -w",
1616
"release": "release-it",
1717
"lint": "eslint ./src --ext ts --report-unused-disable-directives",
18+
"lint:fix": "npm run lint -- --fix && prettier ./src --check --write",
1819
"ingest:all": "ingest all --config ./build/config.js",
1920
"ingest:k8s": "../../node_modules/mongodb-rag-ingest/build/main.js all --config ./build/config.js",
2021
"ingest:pages": "ingest pages --config ./build/config.js",

packages/ingest-mongodb-public/src/sources/mongodbDeveloperCodeRepos.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jest.setTimeout(90000);
2323
describe("mongodbDeveloperCodeRepos", () => {
2424
describe("smoke tests", () => {
2525
test("nodeJsQuickstart", async () => {
26-
smokeTest(nodeJsQuickstart, "usersCollection.js")
26+
smokeTest(nodeJsQuickstart, "usersCollection.js");
2727
});
2828

2929
test("javaQuickstart", async () => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const baseConfig = require(`${__dirname}/../../.prettierrc.cjs`);
2+
3+
module.exports = {
4+
...baseConfig,
5+
};

packages/mongodb-artifact-generator/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"postbuild": "chmod +x build/main.js",
2323
"watch": "tsc -b -w",
2424
"test": "jest --forceExit",
25-
"lint": "eslint ./src --ext js,jsx,ts,tsx --report-unused-disable-directives",
25+
"lint": "eslint ./src --ext ts,tsx,js,jsx --report-unused-disable-directives",
26+
"lint:fix": "npm run lint -- --fix && prettier ./src --check --write",
2627
"parseDriversCsv": "npm run build && node ./build/main.js parseDriversCsv --config='./build/standardConfig.js'"
2728
},
2829
"devDependencies": {

packages/mongodb-artifact-generator/src/Config.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
Embedder,
3-
PageStore,
4-
EmbeddedContentStore,
5-
} from "mongodb-rag-core";
1+
import { Embedder, PageStore, EmbeddedContentStore } from "mongodb-rag-core";
62

73
/**
84
The configuration for the artifact generator.

packages/mongodb-artifact-generator/src/commands/parseDriversCsv.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,15 @@ export const action = createConfiguredAction<ParseDriversCsvCommandArgs>(
111111
const nodeRepoBaseUrl =
112112
"https://github.com/mongodb/docs-node/blob/master/";
113113

114-
115-
type RelevantAssetFields = {
116-
nodeAssetName: string;
117-
nodeAssetRemotePath: string;
118-
nodeAssetPathRelativeToSourceRepo: string;
119-
nodeAssetFullPath: string;
120-
assetType: string;
121-
fileRename?: string;
122-
};
123-
const relevantAssetFieldsOnly = parsedAndNormalized.map(
114+
type RelevantAssetFields = {
115+
nodeAssetName: string;
116+
nodeAssetRemotePath: string;
117+
nodeAssetPathRelativeToSourceRepo: string;
118+
nodeAssetFullPath: string;
119+
assetType: string;
120+
fileRename?: string;
121+
};
122+
const relevantAssetFieldsOnly = parsedAndNormalized.map(
124123
({ nodeAssetName, nodeAssetPath, assetType, fileRename }) => {
125124
const nodeAssetPathRelativeToSourceRepo = nodeAssetPath.replace(
126125
nodeRepoBaseUrl,

packages/mongodb-artifact-generator/src/commands/translateCode.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@ export const action = createConfiguredAction<TranslateCodeCommandArgs>(
153153

154154
logger.logInfo(`Created output:\n\n${transformed}\n`);
155155

156-
157156
const inputFileName = path.parse(source).name;
158-
const outputFileName = `${outputFilename ?? inputFileName}.translated.${targetFileExtension}`;
157+
const outputFileName = `${
158+
outputFilename ?? inputFileName
159+
}.translated.${targetFileExtension}`;
159160
const outputFilePath = outputPath
160161
? path.join(outputPath, outputFileName)
161162
: outputFileName;

packages/mongodb-artifact-generator/src/commands/translateDocsPage.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ import { stripIndents } from "common-tags";
99
import { makeFindContent } from "../vectorSearch";
1010
import { makeGenerateChatCompletion } from "../chat";
1111
import { rewriteAsRst, summarizePage, translatePage } from "../operations";
12-
import {
13-
makeRunLogger,
14-
type RunLogger
15-
} from "../runlogger";
12+
import { makeRunLogger, type RunLogger } from "../runlogger";
1613
import { rstDescription, stringifyVectorSearchChunks } from "../prompt";
17-
import path from "path"
14+
import path from "path";
1815

1916
let logger: RunLogger;
2017

Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { CommandModule } from "yargs";
22
import { LoadConfigArgs } from "./withConfig";
33

4-
type CMD<T extends { [k: string]: unknown } = Record<string, never>> = CommandModule<unknown, LoadConfigArgs & T>;
4+
type CMD<T extends { [k: string]: unknown } = Record<string, never>> =
5+
CommandModule<unknown, LoadConfigArgs & T>;
56

6-
7-
export function createCommand<T extends { [k: string]: unknown } = Record<string, never>>(commandModule: CMD<T>) {
7+
export function createCommand<
8+
T extends { [k: string]: unknown } = Record<string, never>
9+
>(commandModule: CMD<T>) {
810
return commandModule;
911
}

packages/mongodb-artifact-generator/src/pages.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,21 @@ export type FindPagesResult = {
88
pages: Page[];
99
};
1010

11-
export type FindPages = ({
12-
urls,
13-
}: FindPagesArgs) => Promise<FindPagesResult>;
11+
export type FindPages = ({ urls }: FindPagesArgs) => Promise<FindPagesResult>;
1412

1513
export type MakeFindPagesArgs = {
1614
pageStore: PageStore;
1715
};
1816

19-
export function makeFindPages({
20-
pageStore,
21-
}: MakeFindPagesArgs): {
17+
export function makeFindPages({ pageStore }: MakeFindPagesArgs): {
2218
findPages: FindPages;
2319
cleanup: () => Promise<void>;
2420
} {
2521
const findPages: FindPages = async ({ urls }) => {
26-
if(pageStore.queryType !== "mongodb") {
27-
throw new Error(`Unsupported query type: ${pageStore.queryType}. Must be "mongodb".`);
22+
if (pageStore.queryType !== "mongodb") {
23+
throw new Error(
24+
`Unsupported query type: ${pageStore.queryType}. Must be "mongodb".`
25+
);
2826
}
2927
pageStore.loadPages({
3028
query: {

packages/mongodb-artifact-generator/src/prompt.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@ export const rstDescription = html`
126126
127127
* - Charlie
128128
- March 9, 2014
129-
`
129+
`;

packages/mongodb-artifact-generator/src/standardConfig.ts

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const {
1717
MONGODB_DATABASE_NAME,
1818
} = assertEnvVars(ArtifactGeneratorEnvVars);
1919

20-
2120
export const standardConfig = {
2221
embedder: () =>
2322
makeOpenAiEmbedder({

packages/mongodb-artifact-generator/src/yaml.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { promises as fs } from "fs";
22
import path from "path";
33
import YAML from "yaml";
44

5-
export async function readYamlDir(dir: string): Promise<[string, Record<string, unknown>][]> {
5+
export async function readYamlDir(
6+
dir: string
7+
): Promise<[string, Record<string, unknown>][]> {
68
try {
79
const files = await fs.readdir(dir);
810
const yamlFiles = files.filter(
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const baseConfig = require(`${__dirname}/../../.prettierrc.cjs`);
2+
3+
module.exports = {
4+
...baseConfig,
5+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const baseConfig = require(`${__dirname}/../../.prettierrc.cjs`);
2+
3+
module.exports = {
4+
...baseConfig,
5+
};

packages/mongodb-chatbot-evaluation/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"build": "tsc -b tsconfig.build.json",
4040
"postbuild": "chmod +x build/main.js",
4141
"watch": "tsc -b -w",
42-
"lint": "eslint ./src --ext js,jsx,ts,tsx --report-unused-disable-directives",
42+
"lint": "eslint ./src --ext ts --report-unused-disable-directives",
43+
"lint:fix": "npm run lint -- --fix && prettier ./src --check --write",
4344
"release": "release-it",
4445
"test": "jest --forceExit"
4546
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const baseConfig = require(`${__dirname}/../../.prettierrc.cjs`);
2+
3+
module.exports = {
4+
...baseConfig,
5+
};

packages/mongodb-chatbot-server/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"build": "npm run clean && tsc -b tsconfig.build.json",
3232
"format": "prettier ./src --write",
3333
"format:check": "prettier ./src --check",
34-
"lint": "eslint ./src --ext js,jsx,ts,tsx --report-unused-disable-directives",
34+
"lint": "eslint ./src --ext ts,tsx,js,jsx --report-unused-disable-directives",
35+
"lint:fix": "npm run lint -- --fix && prettier ./src --check --write",
3536
"test": "jest --forceExit",
3637
"release": "release-it"
3738
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const baseConfig = require(`${__dirname}/../../.prettierrc.cjs`);
2+
3+
module.exports = {
4+
...baseConfig,
5+
};

packages/mongodb-chatbot-ui/.prettierrc.json

-1
This file was deleted.

packages/mongodb-chatbot-ui/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"env:get-git-commit": "if [ -z \"$VITE_GIT_COMMIT\" ]; then echo \"$(git rev-parse --short HEAD)\"; else echo \"$VITE_GIT_COMMIT\"; fi",
4747
"format": "prettier ./src --write",
4848
"format:check": "prettier ./src --check",
49-
"lint": "eslint ./src --ext js,jsx,ts,tsx --report-unused-disable-directives --max-warnings 0",
49+
"lint": "eslint ./src --ext ts,tsx,js,jsx --report-unused-disable-directives",
50+
"lint:fix": "npm run lint -- --fix && prettier ./src --check --write",
5051
"preview": "vite preview --config vite.config.component.js --mode development",
5152
"preview:static-site:dev": "npm run build:static-site:dev && vite preview --base ./ --config vite.config.static-site.js",
5253
"preview:static-site:staging": "npm run build:static-site:staging && vite preview --base ./ --config vite.config.static-site.js",

packages/mongodb-chatbot-ui/src/InputBar.tsx

+8-6
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ const styles = {
2929
isError,
3030
}: StylesProps & { isError: boolean }) => css`
3131
white-space: nowrap;
32-
color: ${isError
33-
? palette.red.base
34-
: darkMode
35-
? palette.gray.light2
36-
: palette.gray.dark2};
32+
color: ${
33+
isError
34+
? palette.red.base
35+
: darkMode
36+
? palette.gray.light2
37+
: palette.gray.dark2
38+
};
3739
`,
3840
};
3941

@@ -79,7 +81,7 @@ export function CharacterCount({
7981
darkMode,
8082
isError: current > max,
8183
}),
82-
className,
84+
className
8385
)}
8486
>
8587
{`${current} / ${max}`}

0 commit comments

Comments
 (0)