Skip to content

Commit 4aa32f5

Browse files
authored
chore: consolidate eslint rules (googleapis#8155)
* feat: centralize ESLint configurations inside the packages directory * feat: add centralized eslint configurations * test: update expected unique file paths count for consolidated eslint rules * test: resolve Windows-specific test failures in gapic-node-processing
1 parent a9be27a commit 4aa32f5

485 files changed

Lines changed: 36 additions & 2561 deletions

File tree

Some content is hidden

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

packages/gapic-node-processing/test/fixtures/combined-library/google-analytics-data-nodejs/analytics-data-v1alpha-nodejs/.eslintignore renamed to packages/.eslintignore

File renamed without changes.

packages/.eslintrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../node_modules/gts",
3+
"root": true
4+
}

packages/gapic-node-processing/.eslintignore

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

packages/gapic-node-processing/.eslintrc.json

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

packages/gapic-node-processing/src/combine-libraries.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,10 @@ export async function generateFinalDirectoryPath(
162162
const uniquefullPathAndContent = [];
163163

164164
for (const fullPathAndContent of fullPathsAndContents) {
165-
if (!uniquePaths.has(fullPathAndContent.filePath)) {
166-
uniquePaths.add(fullPathAndContent.filePath);
165+
const normalizedPath = fullPathAndContent.filePath.replace(/\\/g, '/');
166+
fullPathAndContent.filePath = normalizedPath;
167+
if (!uniquePaths.has(normalizedPath)) {
168+
uniquePaths.add(normalizedPath);
167169
uniquefullPathAndContent.push(fullPathAndContent);
168170
}
169171
}
@@ -203,9 +205,10 @@ export function setOnlyDefaultSystemTests(
203205

204206
for (let i = filePaths.length - 1; i >= 0; i--) {
205207
const filePathObj = filePaths[i];
208+
const normalizedPath = filePathObj.filePath.replace(/\\/g, '/');
206209
if (
207-
systemTestRegex.test(filePathObj.filePath) &&
208-
!filePathObj.filePath.includes(defaultVersion)
210+
systemTestRegex.test(normalizedPath) &&
211+
!normalizedPath.includes(defaultVersion)
209212
) {
210213
filePaths.splice(i, 1);
211214
}

packages/gapic-node-processing/src/generate-readme.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,19 @@ export async function getSamplesMetadata(
6060
// which we then use to remove from the absolute filePath (so
6161
// /google-cloud-node/packages/gapic-node-processing/test/fixtures/combined-library/google-cloud-speech/samples/generated/v1/adaptation.create_custom_class.js
6262
// becomes just google-cloud-speech/samples/generated/v1/adaptation.create_custom_class.js (the relative path to the new directory)
63-
const stringToRemove = currentLibrary
63+
const normalizedLibrary = currentLibrary.replace(/\\/g, '/');
64+
const stringToRemove = normalizedLibrary
6465
.split('/')
65-
.slice(0, currentLibrary.split('/').length - 1)
66+
.slice(0, normalizedLibrary.split('/').length - 1)
6667
.join('/');
6768

6869
const samples = await traverseDirectory(
6970
path.join(currentLibrary, SAMPLES_PATH),
7071
[],
7172
);
7273
samples.map(sample => {
73-
sample.filePath = sample.filePath
74+
const normalizedSamplePath = sample.filePath.replace(/\\/g, '/');
75+
sample.filePath = normalizedSamplePath
7476
.replace(stringToRemove, '')
7577
.replace('-nodejs', '');
7678
Object.assign(sample, {title: getSampleName(sample)});
@@ -93,9 +95,10 @@ export async function getSamplesMetadata(
9395
*/
9496
export function getSampleName(sample: {filePath: string}): string {
9597
// Get just the sample name from the path
96-
let sampleName = sample.filePath;
98+
const normalizedPath = sample.filePath.replace(/\\/g, '/');
99+
let sampleName = normalizedPath;
97100
try {
98-
sampleName = sampleName.split('/')[sample.filePath.split('/').length - 1];
101+
sampleName = sampleName.split('/')[normalizedPath.split('/').length - 1];
99102
// Remove the API name
100103
sampleName = sampleName.split('.')[1];
101104
// Remove the .js

packages/gapic-node-processing/test/combine-libraries.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('combine libraries', () => {
8484
it('should generate unique final directory paths', async () => {
8585
const libraryPaths = await generateFinalDirectoryPath(libraryConfigCJS);
8686
// This should be the amount of unique file paths in the tree directory
87-
assert.deepStrictEqual(libraryPaths.length, 102);
87+
assert.deepStrictEqual(libraryPaths.length, 100);
8888

8989
// Confirm there are only unique items in the array
9090
assert.deepStrictEqual(

packages/gapic-node-processing/test/fixtures/combined-library/google-analytics-data-nodejs/analytics-data-v1alpha-nodejs/.eslintrc.json

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

packages/gapic-node-processing/test/fixtures/combined-library/google-analytics-data-nodejs/google-analytics-data-v1beta-nodejs/.eslintignore

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

packages/gapic-node-processing/test/fixtures/combined-library/google-analytics-data-nodejs/google-analytics-data-v1beta-nodejs/.eslintrc.json

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

0 commit comments

Comments
 (0)