fix(linter): add @nrwl/linter as a devDependency and error on improper enum schema (#4634)
This commit is contained in:
parent
14503c27c9
commit
b36c4b5cc1
@ -105,7 +105,7 @@ describe('Linter', () => {
|
|||||||
/'tslint' option is no longer supported/
|
/'tslint' option is no longer supported/
|
||||||
);
|
);
|
||||||
expect(() => runCLI(`lint ${myapp} --linter=random`)).toThrow(
|
expect(() => runCLI(`lint ${myapp} --linter=random`)).toThrow(
|
||||||
/Schema validation failed/
|
/'random' should be one of eslint,tslint/
|
||||||
);
|
);
|
||||||
}, 1000000);
|
}, 1000000);
|
||||||
|
|
||||||
|
|||||||
@ -377,12 +377,20 @@ describe('app', () => {
|
|||||||
expect(eslintJson.extends).toEqual(
|
expect(eslintJson.extends).toEqual(
|
||||||
expect.arrayContaining(['plugin:@nrwl/nx/react'])
|
expect.arrayContaining(['plugin:@nrwl/nx/react'])
|
||||||
);
|
);
|
||||||
expect(packageJson).toMatchObject({
|
expect(packageJson.devDependencies.eslint).toBeDefined();
|
||||||
devDependencies: {
|
expect(packageJson.devDependencies['@nrwl/linter']).toBeDefined();
|
||||||
'eslint-plugin-react': expect.anything(),
|
expect(packageJson.devDependencies['@nrwl/eslint-plugin-nx']).toBeDefined();
|
||||||
'eslint-plugin-react-hooks': expect.anything(),
|
expect(packageJson.devDependencies['eslint-plugin-react']).toBeDefined();
|
||||||
},
|
expect(
|
||||||
});
|
packageJson.devDependencies['eslint-plugin-react-hooks']
|
||||||
|
).toBeDefined();
|
||||||
|
expect(
|
||||||
|
packageJson.devDependencies['@typescript-eslint/parser']
|
||||||
|
).toBeDefined();
|
||||||
|
expect(
|
||||||
|
packageJson.devDependencies['@typescript-eslint/eslint-plugin']
|
||||||
|
).toBeDefined();
|
||||||
|
expect(packageJson.devDependencies['eslint-config-prettier']).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('--class-component', () => {
|
describe('--class-component', () => {
|
||||||
|
|||||||
@ -226,6 +226,14 @@ function validateProperty(
|
|||||||
`Property '${propName}' does not match the schema. '${value}' should be a '${schema.type}'.`
|
`Property '${propName}' does not match the schema. '${value}' should be a '${schema.type}'.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (schema.enum && !schema.enum.includes(value)) {
|
||||||
|
throw new SchemaError(
|
||||||
|
`Property '${propName}' does not match the schema. '${value}' should be one of ${schema.enum.join(
|
||||||
|
','
|
||||||
|
)}.`
|
||||||
|
);
|
||||||
|
}
|
||||||
} else if (Array.isArray(value)) {
|
} else if (Array.isArray(value)) {
|
||||||
if (schema.type !== 'array') throwInvalidSchema(propName, schema);
|
if (schema.type !== 'array') throwInvalidSchema(propName, schema);
|
||||||
value.forEach((valueInArray) =>
|
value.forEach((valueInArray) =>
|
||||||
|
|||||||
@ -115,6 +115,7 @@ export function addLintFiles(
|
|||||||
: {}),
|
: {}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
'@nrwl/linter': nxVersion,
|
||||||
'@nrwl/eslint-plugin-nx': nxVersion,
|
'@nrwl/eslint-plugin-nx': nxVersion,
|
||||||
'@typescript-eslint/parser': typescriptESLintVersion,
|
'@typescript-eslint/parser': typescriptESLintVersion,
|
||||||
'@typescript-eslint/eslint-plugin': typescriptESLintVersion,
|
'@typescript-eslint/eslint-plugin': typescriptESLintVersion,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user