Skip to content

Commit

Permalink
Fix: Hide configuration-all from the user
Browse files Browse the repository at this point in the history
This configuration is only for internal consumption to get easy access
to all the documentation and should never be used by a user as it can
cause problems when extending from it.

This PR filters it when running `npm init hintrc` and verifies the
`.hintrc` doesn't `extends` from it.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Fix #3097
  • Loading branch information
molant committed Nov 19, 2019
1 parent dab1c16 commit b628eb4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/create-hintrc/src/create-hintrc.ts
Expand Up @@ -64,13 +64,17 @@ const extendConfig = async (): Promise<InitUserConfig | null> => {
return null;
}

const choices = configPackages.map((pkg) => {
const configNames = configPackages.map((pkg) => {
return {
name: getConfigurationName(pkg.name),
value: pkg.name
};
});

const choices = configNames.filter((config) => {
return config.name !== 'all';
});

const questions: inquirer.Questions = [{
choices,
message: 'Choose the configuration you want to extend from',
Expand Down
3 changes: 2 additions & 1 deletion packages/hint/src/lib/config/config-schema.json
Expand Up @@ -98,7 +98,8 @@
"description": "Base configuration to use.",
"type": "array",
"items": {
"type": "string"
"type": "string",
"pattern": "^(?!all$).*$"
},
"uniqueItems": true
},
Expand Down
7 changes: 7 additions & 0 deletions packages/hint/tests/lib/config/config-validator.ts
Expand Up @@ -64,6 +64,7 @@ const invalidHintsConfigArrayFormArrayInverted = {
hints: [[{}, 'no-html-only-headers:error']]
};

const invalidExtends = { extends: ['all'] };

test('If config has an invalid schema, it should return false', (t) => {
const valid = configValidator.validateConfig(invalidConfig as any);
Expand Down Expand Up @@ -118,3 +119,9 @@ test('If the configuration uses shorthands, it should validate', (t) => {

t.true(valid);
});

test('If config extends from "all" is should not validate', (t) => {
const invalid = configValidator.validateConfig(invalidExtends as any);

t.false(invalid);
});

0 comments on commit b628eb4

Please sign in to comment.