@sshkeda/check 4.2.0 → 4.3.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.
|
@@ -19,7 +19,7 @@ export default lintConfig({
|
|
|
19
19
|
- `usesAbbreviations`: Allows abbreviations in variable, function, type and other declared names.
|
|
20
20
|
- `pollsWithADeadline`: Allows `Effect.repeat` and `Effect.retry` with `Schedule.spaced` or `Schedule.exponential`, under a deadline. `Schedule.exponential` may be wrapped in or piped through `Schedule.jittered`.
|
|
21
21
|
- `waitsOnTimers`: Allows `Effect.sleep`, `Effect.delay`, `Clock.sleep` and the Stream operations that wait on a timer, such as `Stream.tick`.
|
|
22
|
-
- `hasAnUnlistedFileType`: Allows a file type Check doesn't list, such as Markdown.
|
|
22
|
+
- `hasAnUnlistedFileType`: Allows a file type Check doesn't list, such as Markdown outside `docs/`. Markdown in `docs/` and the root `README.md` pass as they are.
|
|
23
23
|
- `isAnUnlistedDirectory`: Allows a directory Check doesn't list, such as `.github`. Check doesn't apply its directory-shape rules inside it, but files there still need their own `hasAnUnlistedFileType` grant.
|
|
24
24
|
- `patchesADependency`: Allows a patch file from `bun patch`.
|
|
25
25
|
- `trustsUnverifiedTypes`: Allows trusting a value's type without checking it, through `Schema.declare`.
|
|
@@ -10,6 +10,7 @@ Check may not catch every violation of these principles. Review your code agains
|
|
|
10
10
|
- Move the code that needs a grant into its own small file and grant that file. A grant covers the whole file, so Check stops reporting that ban for everything else in it.
|
|
11
11
|
- Design for the current requirement as if you were starting fresh. Delete code the new design doesn't need.
|
|
12
12
|
- Handle a forked effect's failure before the fork, or keep the fiber and join it.
|
|
13
|
+
- Wrap a Promise in `Effect.tryPromise` and `yield*` it instead of using `await`.
|
|
13
14
|
- Read a fact from where a tool states it, such as an error's fields, a command's exit code or its JSON output. Text written for people changes between releases, and code that searches it breaks quietly when it does.
|
|
14
15
|
- Return a fixed value only for the one failure you expect, such as a file that isn't there. Let every other failure fail.
|
|
15
16
|
- Write a job that moves through stages as an explicit state machine, with one tagged case per stage in one union, so the job is always in exactly one stage.
|
package/package.json
CHANGED
|
@@ -235,6 +235,7 @@ const baseConfig = {
|
|
|
235
235
|
"eslint/no-else-return": "error",
|
|
236
236
|
"eslint/no-empty": "error",
|
|
237
237
|
"eslint/no-empty-function": ["error", { allow: ["privateConstructors"] }],
|
|
238
|
+
"eslint/no-extend-native": "error",
|
|
238
239
|
"eslint/no-implicit-coercion": "error",
|
|
239
240
|
"eslint/no-lone-blocks": "error",
|
|
240
241
|
"eslint/no-lonely-if": "error",
|
|
@@ -275,6 +276,7 @@ const baseConfig = {
|
|
|
275
276
|
"typescript/no-empty-object-type": "error",
|
|
276
277
|
"typescript/no-explicit-any": "error",
|
|
277
278
|
"typescript/no-extraneous-class": "error",
|
|
279
|
+
"typescript/no-floating-promises": ["error", { ignoreVoid: false, checkThenables: true }],
|
|
278
280
|
"typescript/no-import-type-side-effects": "error",
|
|
279
281
|
"typescript/no-inferrable-types": "error",
|
|
280
282
|
"typescript/no-misused-promises": "error",
|
|
@@ -464,6 +464,10 @@ export const manifestViolations = (
|
|
|
464
464
|
|
|
465
465
|
const ROOT_README = "README.md";
|
|
466
466
|
|
|
467
|
+
const isMarkdownInDocs = (path: string) => isMarkdown(path) && isWithin(path, DOCS_DIRECTORY);
|
|
468
|
+
|
|
469
|
+
const needsNoDocumentGrant = (path: string) => path === ROOT_README || isMarkdownInDocs(path);
|
|
470
|
+
|
|
467
471
|
export const permissionGrantViolations = (
|
|
468
472
|
paths: readonly string[],
|
|
469
473
|
grants: Effect.Success<ReturnType<typeof loadedLintConfigIn>>,
|
|
@@ -500,7 +504,7 @@ export const permissionGrantViolations = (
|
|
|
500
504
|
for (const path of paths) {
|
|
501
505
|
const isUngrantedDocument =
|
|
502
506
|
isMarkdown(path) &&
|
|
503
|
-
path
|
|
507
|
+
!needsNoDocumentGrant(path) &&
|
|
504
508
|
!generated.has(path) &&
|
|
505
509
|
!isGranted(path, FILE_TYPE);
|
|
506
510
|
if (isUngrantedDocument) {
|
|
@@ -538,8 +542,9 @@ export const permissionGrantViolations = (
|
|
|
538
542
|
if (isDirectoryGrantedPermissions) {
|
|
539
543
|
violations.push(new DirectoryGrantedPermissions({ path: grant.path }));
|
|
540
544
|
}
|
|
541
|
-
const
|
|
542
|
-
grant.path
|
|
545
|
+
const grantsFileTypeToExistingFile =
|
|
546
|
+
repositoryFiles.has(grant.path) && grant.allow.includes(FILE_TYPE);
|
|
547
|
+
const grantsFileTypeToRootReadme = grantsFileTypeToExistingFile && grant.path === ROOT_README;
|
|
543
548
|
if (grantsFileTypeToRootReadme) {
|
|
544
549
|
violations.push(
|
|
545
550
|
new RedundantGrant({
|
|
@@ -549,6 +554,17 @@ export const permissionGrantViolations = (
|
|
|
549
554
|
}),
|
|
550
555
|
);
|
|
551
556
|
}
|
|
557
|
+
const grantsFileTypeToMarkdownInDocs =
|
|
558
|
+
grantsFileTypeToExistingFile && isMarkdownInDocs(grant.path);
|
|
559
|
+
if (grantsFileTypeToMarkdownInDocs) {
|
|
560
|
+
violations.push(
|
|
561
|
+
new RedundantGrant({
|
|
562
|
+
path: grant.path,
|
|
563
|
+
permission: FILE_TYPE,
|
|
564
|
+
reason: `Markdown in ${DOCS_DIRECTORY}/ needs no grant`,
|
|
565
|
+
}),
|
|
566
|
+
);
|
|
567
|
+
}
|
|
552
568
|
for (const target of grant.cannotImport.filter((candidate) => !exists(candidate))) {
|
|
553
569
|
violations.push(new CannotImportTargetMissing({ path: grant.path, target }));
|
|
554
570
|
}
|