nx/packages/schematics/migrations/20171202-change-schema.ts
Emilio Martinez-Cordero b3f67351fe feat(schematics): add allow option to whitelist deep imports
Adds an `allow` option to the `nx-enforce-module-boundaries` rule.

This option allows users to provide a specific set of library deep imports that should be whitelisted. Values need to be to be absolute library import paths, e.g., `@npmScope/library/subdirectory`. This option does not affect relative imports.
2017-12-03 15:30:57 -05:00

18 lines
639 B
TypeScript

import { updateJsonFile } from '../src/collection/utility/fileutils';
export default {
description: 'Update the schema file to reflect the `allow` option for `nx-enforce-module-boundaries`.',
run: () => {
updateJsonFile('tslint.json', json => {
const ruleName = 'nx-enforce-module-boundaries';
const ruleOptionName = 'allow';
const rule = ruleName in json.rules ? json.rules[ruleName] : null;
// Only modify when the rule is configured with optional arguments
if (Array.isArray(rule) && typeof rule[2] === 'object' && rule[2] !== null) {
rule[2][ruleOptionName] = [];
}
});
}
};