Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Yarn-related rules #39

Merged
merged 18 commits into from
Jan 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't throw in require-valid-package-manifest either
mcmire committed Jan 4, 2024
commit e1fe87870bfb5ab651755f12b87ab5cc86e82eab
7 changes: 2 additions & 5 deletions src/rules/require-valid-package-manifest.test.ts
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ describe('Rule: require-package-manifest', () => {
});
});

it('fails if the project has a malformed package.json', async () => {
it('passes if the project has a malformed package.json', async () => {
expect.assertions(1);

await withinSandbox(async (sandbox) => {
@@ -80,10 +80,7 @@ describe('Rule: require-package-manifest', () => {
});

expect(result).toStrictEqual({
passed: false,
failures: [
{ message: 'Invalid `package.json`: Missing `packageManager`.' },
],
passed: true,
});
});
});
5 changes: 2 additions & 3 deletions src/rules/require-valid-package-manifest.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
description: 'Does the package have a well-formed manifest (`package.json`)?',
dependencies: [],
execute: async (ruleExecutionArguments) => {
const { project, pass, fail } = ruleExecutionArguments;

Check failure on line 12 in src/rules/require-valid-package-manifest.ts

GitHub Actions / Build, lint, and test / Lint (16.x)

'fail' is assigned a value but never used

Check failure on line 12 in src/rules/require-valid-package-manifest.ts

GitHub Actions / Build, lint, and test / Lint (18.x)

'fail' is assigned a value but never used

Check failure on line 12 in src/rules/require-valid-package-manifest.ts

GitHub Actions / Build, lint, and test / Lint (20.x)

'fail' is assigned a value but never used
const entryPath = 'package.json';

const fileExistsResult = await fileExists(
@@ -29,9 +29,8 @@
isErrorWithMessage(error) &&
error.code === 'ERR_INVALID_JSON_FILE'
kanthesha marked this conversation as resolved.
Show resolved Hide resolved
) {
return fail([
{ message: `Invalid \`${entryPath}\`: ${error.message}` },
]);
console.warn(`Invalid \`${entryPath}\`: ${error.message}`);
return pass();
}
throw error;
}