modern.js icon indicating copy to clipboard operation
modern.js copied to clipboard

[Bug]: The configuration file schema validation is too loose.

Open KyrieLii opened this issue 2 years ago • 1 comments

Version

System:
    OS: macOS 12.5.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 125.14 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Browsers:
    Chrome: 115.0.5790.170
    Safari: 15.6.1

Details

For example, there is no error report while I use runtime.router in configuration file, but actually I am not install @modern-js/runtime.

So I try to change the initial validate schema to fix it ( may be not appropriate because lead to wider impact), it caused more errors in test cases.

Another question is app-toolsmodule-tools and doc-tools shared common initial schema in packages/cli/core/src/schema/patchSchema.ts , I think it is not good, because some config params can not be shared.

This isssue can be divided into two parts for resolution:

  1. Ensure that the params are defined within the plugin and implement validation logic within the plugin itself.
  2. Define validation logic for the resolution level separately.

Is there a better way? welcome discussion~

https://github.com/web-infra-dev/modern.js/pull/4378

Reproduce link

no

Reproduce Steps

no

KyrieLii avatar Aug 07 '23 02:08 KyrieLii

Ajv provide a config called additionalProperties to validate additional properties like runtime, but we cannot use it in app-tools because some additional properties are provided by Modern.js Builder, we cannot disallow all additional properties...

chenjiahan avatar Aug 09 '23 07:08 chenjiahan

We have removed all Ajv.

zllkjc avatar Jul 09 '24 12:07 zllkjc