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

Support checksyncrc files #812

Merged
merged 20 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
18 changes: 18 additions & 0 deletions .checksyncrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "./src/checksync.schema.json",
"$comment": "This is the config file for our integration tests. By not specifying it directly, we also test configuration file discovery.",
"autoFix": false,
"comments": [
"//",
"#",
"{/*"
],
"dryRun": false,
"excludeGlobs": [
"**/excluded/**"
],
"ignoreFiles": [
"**/ignore-file.txt"
],
"json": false
}
Comment on lines +1 to +18
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example config file for checksync. Note that the schema can be specified at the top of the file as per JSON Schema specifications (the schema is shipped with the tool).

Note that folks don't need to include this - their configs will still be validated against this schema, regardless. However, for tools like VSCode, this tells it what schema to use and provides autocomplete/intellisense accordingly.

9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@
"editor.formatOnSave": true,
"javascript.validate.enable": false,
"typescript.validate.enable": false,
"json.schemas": [
{
"fileMatch": [
"**/.checksyncrc",
"**/.checksyncrc.json"
],
"url": "./src/checksync.schema.json"
}
],
somewhatabstract marked this conversation as resolved.
Show resolved Hide resolved
}
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,6 @@ To get more information about the various arguments that `checksync` supports as

All target paths are relative to your project root directory. By default, this is determined, using `ancesdir` to be the ancestor directory of the files being processed that contains `package.json`. If you want to specify a different root (for example, if you're syncing across multiple packages in a monorepo) you can specify a custom marker name using the `--root-marker` argument.

### Comment styles

By default, `checksync` supports comment lines that begin with `//` and `#` as commonly found in JavaScript, Python, and other languages. You can override this default using the `--comments` or `-c` argument.

```shell
yarn checksync -c="//,#,'" <globs|files|dirs>
```

### Ignoring files

`checksync` supports both a comma-separated list of globs (via `--ignore`) and a comma-separated list of `.gitignore` style files (via `--ignore-files`) to control what files are ignored. By default, the `.gitignore` file is used unless the `--no-ignore-file` argument is used.

## Contributing

For details on contributing to `checksync`, checkout our [contribution guidelines](CONTRIBUTING.md).
2 changes: 1 addition & 1 deletion bin/checksync.dev.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node
require("@babel/register");
require("../src/main.js").run(__filename);
require("../src/main.js").runCli(__filename);
2 changes: 1 addition & 1 deletion bin/checksync.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require("../dist/main.js").run(__filename);
require("../dist/main.js").runCli(__filename);
55 changes: 55 additions & 0 deletions flow-typed/hyperjump-json-schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
declare module "@hyperjump/json-schema" {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pieced this together from typescript and reading the code.

declare opaque type Schema;

declare type SDoc = {
anchors: mixed,
dynamicAnchors: mixed,
id: string,
pointer: string,
schema: Schema,
schemaVersion: string,
validated: boolean,
value: Schema,
vocabulary: mixed,
};

declare opaque type Keywords;

declare type OutputFormat = "FLAG" | "BASIC" | "DETAILED" | "VERBOSE";

declare type OutputUnit = {
absoluteKeywordLocation: string,
errors: $ReadOnlyArray<OutputUnit>,
instanceLocation: string,
keyword: string,
valid: boolean,
};

declare type AST = mixed;

declare type CompiledSchema = {
ast: AST,
schemaUri: string,
};

declare interface JsonSchema {
add: (schema: SDoc, url?: string, defaultSchemaVersion?: string) => void,
get: (url: string, contextDoc?: SDoc) => Promise<SDoc>,
validate: (schema: SDoc, value: {...}, outputFormat?: OutputFormat) => Promise<OutputUnit>,
compile: (schema: SDoc) => Promise<CompiledSchema>;
interpret: interface {
(schema: CompiledSchema, value: {...}): (outputFormat?: OutputFormat) => OutputUnit;
(schema: CompiledSchema): (value: {...}, outputFormat?: OutputFormat) => OutputUnit;
(schema: CompiledSchema, value: {...}, outputFormat?: OutputFormat): () => OutputUnit;
},
setMetaOutputFormat: (outputFormat?: OutputFormat) => void,
setShouldMetaValidate: (isEnabled: boolean) => void,
FLAG: "FLAG",
BASIC: "BASIC",
DETAILED: "DETAILED",
VERBOSE: "VERBOSE",
Keywords: Keywords
}

declare module.exports: JsonSchema;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// flow-typed signature: 8af4d93597d645140f12c00de2a323bc
// flow-typed version: c6154227d1/chalk_v2.x.x/flow_>=v0.104.x
// flow-typed signature: 5096c316b7092ffc5ddc487d26c0d6a4
// flow-typed version: f2e3dcf9e8/chalk_v4.x.x/flow_>=v0.104.x

// From: https://github.com/chalk/chalk/blob/master/index.js.flow
// From: https://github.com/chalk/chalk/blob/master/index.d.ts

declare module "chalk" {
declare type TemplateStringsArray = $ReadOnlyArray<string>;
Expand All @@ -15,7 +15,6 @@ declare module "chalk" {
}>;

declare type ChalkOptions = {|
enabled?: boolean,
level?: Level
|};

Expand All @@ -29,8 +28,7 @@ declare module "chalk" {
declare interface Chalk {
(...text: string[]): string,
(text: TemplateStringsArray, ...placeholders: string[]): string,
constructor(options?: ChalkOptions): Chalk,
enabled: boolean,
Instance(options?: ChalkOptions): Chalk,
level: Level,
rgb(r: number, g: number, b: number): Chalk,
hsl(h: number, s: number, l: number): Chalk,
Expand Down
Loading