From 334c8590c6def748243b67c08074608ed00a41bf Mon Sep 17 00:00:00 2001 From: Boshen Date: Thu, 11 Jul 2024 09:45:53 +0800 Subject: [PATCH] u --- .github/workflows/ci.yml | 2 +- crates/oxc_linter/src/lib.rs | 14 +- .../oxc_linter/src/snapshots/schema_json.snap | 288 ------------------ justfile | 4 - 4 files changed, 9 insertions(+), 299 deletions(-) delete mode 100644 crates/oxc_linter/src/snapshots/schema_json.snap diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8bfe0e1af00644..e691b399bbee44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,6 @@ jobs: test: needs: optimize_ci - if: needs.optimize_ci.outputs.skip == 'false' name: Test strategy: fail-fast: false @@ -76,6 +75,7 @@ jobs: - run: cargo ck - run: cargo test --no-run - run: cargo test + - run: git diff --exit-code # Everything should be commited test-windows: needs: optimize_ci diff --git a/crates/oxc_linter/src/lib.rs b/crates/oxc_linter/src/lib.rs index 686c1938c67d1b..b418b755404817 100644 --- a/crates/oxc_linter/src/lib.rs +++ b/crates/oxc_linter/src/lib.rs @@ -152,18 +152,20 @@ mod test { #[test] fn test_schema_json() { - use std::fs; - use project_root::get_project_root; + use std::fs; let path = get_project_root().unwrap().join("npm/oxlint/configuration_schema.json"); + let existing_json = fs::read_to_string(&path).unwrap_or_default(); let schema = schemars::schema_for!(OxlintConfig); let json = serde_json::to_string_pretty(&schema).unwrap(); - let existing_json = fs::read_to_string(&path).unwrap_or_default(); if existing_json != json { std::fs::write(&path, &json).unwrap(); } - insta::with_settings!({ prepend_module_to_snapshot => false }, { - insta::assert_snapshot!(json); - }); + let s = fs::read_to_string(&path).expect("file exits"); + let json = serde_json::from_str::(&s).expect("is json"); + assert_eq!( + json.as_object().unwrap().get("title").unwrap().as_str().unwrap(), + "OxlintConfig" + ); } } diff --git a/crates/oxc_linter/src/snapshots/schema_json.snap b/crates/oxc_linter/src/snapshots/schema_json.snap deleted file mode 100644 index fe08174cde2602..00000000000000 --- a/crates/oxc_linter/src/snapshots/schema_json.snap +++ /dev/null @@ -1,288 +0,0 @@ ---- -source: crates/oxc_linter/src/lib.rs -expression: json ---- -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "OxlintConfig", - "description": "Oxlint Configuration File\n\nThis configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).\n\nUsage: `oxlint -c oxlintrc.json`\n\n::: danger NOTE\n\nOnly the `.json` format is supported.\n\n:::\n\nExample\n\n`.oxlintrc.json`\n\n```json { \"env\": { \"browser\": true }, \"globals\": { \"foo\": \"readonly\" }, \"settings\": { }, \"rules\": { \"eqeqeq\": \"warn\" } } ```", - "type": "object", - "properties": { - "env": { - "$ref": "#/definitions/OxlintEnv" - }, - "globals": { - "$ref": "#/definitions/OxlintGlobals" - }, - "rules": { - "description": "See [Oxlint Rules](./rules)", - "allOf": [ - { - "$ref": "#/definitions/OxlintRules" - } - ] - }, - "settings": { - "$ref": "#/definitions/OxlintSettings" - } - }, - "definitions": { - "AllowWarnDeny": { - "oneOf": [ - { - "description": "Oxlint rule.\n- \"allow\" or \"off\": Turn off the rule.\n- \"warn\": Turn the rule on as a warning (doesn't affect exit code).\n- \"error\" or \"deny\": Turn the rule on as an error (will exit with a failure code).", - "type": "string", - "enum": [ - "allow", - "off", - "warn", - "error", - "deny" - ] - }, - { - "description": "Oxlint rule.\n \n- 0: Turn off the rule.\n- 1: Turn the rule on as a warning (doesn't affect exit code).\n- 2: Turn the rule on as an error (will exit with a failure code).", - "type": "integer", - "format": "uint32", - "maximum": 2.0, - "minimum": 0.0 - } - ] - }, - "CustomComponent": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "object", - "required": [ - "attribute", - "name" - ], - "properties": { - "attribute": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - { - "type": "object", - "required": [ - "attributes", - "name" - ], - "properties": { - "attributes": { - "type": "array", - "items": { - "type": "string" - } - }, - "name": { - "type": "string" - } - } - } - ] - }, - "DummyRule": { - "anyOf": [ - { - "$ref": "#/definitions/AllowWarnDeny" - }, - { - "type": "array", - "items": true - } - ] - }, - "GlobalValue": { - "type": "string", - "enum": [ - "readonly", - "writeable", - "off" - ] - }, - "JSDocPluginSettings": { - "type": "object", - "properties": { - "augmentsExtendsReplacesDocs": { - "description": "Only for `require-(yields|returns|description|example|param|throws)` rule", - "default": false, - "type": "boolean" - }, - "exemptDestructuredRootsFromChecks": { - "description": "Only for `require-param-type` and `require-param-description` rule", - "default": false, - "type": "boolean" - }, - "ignoreInternal": { - "description": "For all rules but NOT apply to `empty-tags` rule", - "default": false, - "type": "boolean" - }, - "ignorePrivate": { - "description": "For all rules but NOT apply to `check-access` and `empty-tags` rule", - "default": false, - "type": "boolean" - }, - "ignoreReplacesDocs": { - "description": "Only for `require-(yields|returns|description|example|param|throws)` rule", - "default": true, - "type": "boolean" - }, - "implementsReplacesDocs": { - "description": "Only for `require-(yields|returns|description|example|param|throws)` rule", - "default": false, - "type": "boolean" - }, - "overrideReplacesDocs": { - "description": "Only for `require-(yields|returns|description|example|param|throws)` rule", - "default": true, - "type": "boolean" - }, - "tagNamePreference": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/TagNamePreference" - } - } - } - }, - "JSXA11yPluginSettings": { - "type": "object", - "properties": { - "components": { - "default": {}, - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "polymorphicPropName": { - "type": [ - "string", - "null" - ] - } - } - }, - "NextPluginSettings": { - "type": "object", - "properties": { - "rootDir": { - "$ref": "#/definitions/OneOrMany_for_String" - } - } - }, - "OneOrMany_for_String": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "array", - "items": { - "type": "string" - } - } - ] - }, - "OxlintEnv": { - "description": "Predefine global variables.", - "type": "object", - "additionalProperties": { - "type": "boolean" - } - }, - "OxlintGlobals": { - "description": "Add or remove global variables.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/GlobalValue" - } - }, - "OxlintRules": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/DummyRule" - } - }, - "OxlintSettings": { - "description": "Shared settings for plugins", - "type": "object", - "properties": { - "jsdoc": { - "$ref": "#/definitions/JSDocPluginSettings" - }, - "jsx-a11y": { - "$ref": "#/definitions/JSXA11yPluginSettings" - }, - "next": { - "$ref": "#/definitions/NextPluginSettings" - }, - "react": { - "$ref": "#/definitions/ReactPluginSettings" - } - } - }, - "ReactPluginSettings": { - "type": "object", - "properties": { - "formComponents": { - "type": "array", - "items": { - "$ref": "#/definitions/CustomComponent" - } - }, - "linkComponents": { - "type": "array", - "items": { - "$ref": "#/definitions/CustomComponent" - } - } - } - }, - "TagNamePreference": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "object", - "required": [ - "message", - "replacement" - ], - "properties": { - "message": { - "type": "string" - }, - "replacement": { - "type": "string" - } - } - }, - { - "type": "object", - "required": [ - "message" - ], - "properties": { - "message": { - "type": "string" - } - } - }, - { - "type": "boolean" - } - ] - } - } -} diff --git a/justfile b/justfile index d9d4700d25b9ae..a58cf069079baa 100755 --- a/justfile +++ b/justfile @@ -148,10 +148,6 @@ clone-submodule dir url sha: git clone --depth=1 {{url}} {{dir}} || true cd {{dir}} && git fetch origin {{sha}} && git reset --hard {{sha}} -# Re-genenerate the JSON schema for oxlint's config. -linter-schema: - cargo run -p website -- linter-schema-json > npm/oxlint/configuration_schema.json - website path: cargo run -p website -- linter-rules > {{path}}/src/docs/guide/usage/linter/generated-rules.md cargo run -p website -- linter-cli > {{path}}/src/docs/guide/usage/linter/generated-cli.md