Skip to content

Commit

Permalink
cleanup(angular): ban imports from @nrwl/workspace entry point (#9341)
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Mar 15, 2022
1 parent 86aaeb6 commit 7ae6d48
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 17 deletions.
7 changes: 7 additions & 0 deletions packages/angular/.eslintrc.json
Expand Up @@ -14,6 +14,13 @@
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["**/*.ts"],
"excludedFiles": ["./src/migrations/**"],
"rules": {
"no-restricted-imports": ["error", "@nrwl/workspace"]
}
}
]
}
@@ -1,6 +1,6 @@
import type { Tree } from '@nrwl/devkit';
import { joinPathFragments, offsetFromRoot, writeJson } from '@nrwl/devkit';
import { stringUtils } from '@nrwl/workspace';
import { camelize, dasherize } from '@nrwl/workspace/src/utils/strings';
import type { AddLintingGeneratorSchema } from '../schema';

export function createEsLintConfiguration(
Expand Down Expand Up @@ -44,15 +44,15 @@ export function createEsLintConfiguration(
'error',
{
type: 'attribute',
prefix: stringUtils.camelize(options.prefix),
prefix: camelize(options.prefix),
style: 'camelCase',
},
],
'@angular-eslint/component-selector': [
'error',
{
type: 'element',
prefix: stringUtils.dasherize(options.prefix),
prefix: dasherize(options.prefix),
style: 'kebab-case',
},
],
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/generators/application/application.ts
Expand Up @@ -5,7 +5,7 @@ import {
Tree,
} from '@nrwl/devkit';
import { wrapAngularDevkitSchematic } from '@nrwl/devkit/ngcli-adapter';
import { convertToNxProjectGenerator } from '@nrwl/workspace';
import { convertToNxProjectGenerator } from '@nrwl/workspace/generators';
import { UnitTestRunner } from '../../utils/test-runners';
import { angularInitGenerator } from '../init/init';
import { setupTailwindGenerator } from '../setup-tailwind/setup-tailwind';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/generators/application/lib/add-e2e.ts
Expand Up @@ -8,7 +8,7 @@ import { E2eTestRunner } from '../../../utils/test-runners';
import { addProtractor } from './add-protractor';
import { removeScaffoldedE2e } from './remove-scaffolded-e2e';
import { updateE2eProject } from './update-e2e-project';
import { convertToNxProjectGenerator } from '@nrwl/workspace';
import { convertToNxProjectGenerator } from '@nrwl/workspace/generators';
import { Linter, lintProjectGenerator } from '@nrwl/linter';
import { getWorkspaceLayout, joinPathFragments } from '@nrwl/devkit';

Expand Down
Expand Up @@ -9,7 +9,7 @@ import {
removeProjectConfiguration,
offsetFromRoot,
} from '@nrwl/devkit';
import { replaceAppNameWithPath } from '@nrwl/workspace';
import { replaceAppNameWithPath } from '@nrwl/workspace/src/utils/cli-config-utils';
import { E2eTestRunner, UnitTestRunner } from '../../../utils/test-runners';

export function updateConfigFiles(host: Tree, options: NormalizedSchema) {
Expand Down
Expand Up @@ -8,7 +8,7 @@ import {
updateJson,
updateProjectConfiguration,
} from '@nrwl/devkit';
import { replaceAppNameWithPath } from '@nrwl/workspace';
import { replaceAppNameWithPath } from '@nrwl/workspace/src/utils/cli-config-utils';
import { getRelativePathToRootTsConfig } from '@nrwl/workspace/src/utilities/typescript';
import * as path from 'path';
import { NormalizedSchema } from './normalized-schema';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/generators/library/library.ts
Expand Up @@ -8,7 +8,7 @@ import {
import { wrapAngularDevkitSchematic } from '@nrwl/devkit/ngcli-adapter';
import { jestProjectGenerator } from '@nrwl/jest';
import { Linter } from '@nrwl/linter';
import { convertToNxProjectGenerator } from '@nrwl/workspace';
import { convertToNxProjectGenerator } from '@nrwl/workspace/generators';
import init from '../../generators/init/init';
import { postcssVersion } from '../../utils/versions';
import addLintingGenerator from '../add-linting/add-linting';
Expand Down
@@ -1,6 +1,6 @@
import { Tree } from '@nrwl/devkit';
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
import { moveGenerator } from '@nrwl/workspace';
import { moveGenerator } from '@nrwl/workspace/generators';
import { Schema } from '../schema';
import { updateModuleName } from './update-module-name';
import libraryGenerator from '../../library/library';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/generators/move/move.ts
@@ -1,5 +1,5 @@
import { convertNxGenerator, formatFiles, Tree } from '@nrwl/devkit';
import { moveGenerator } from '@nrwl/workspace';
import { moveGenerator } from '@nrwl/workspace/generators';
import { updateModuleName } from './lib/update-module-name';
import { updateNgPackage } from './lib/update-ng-package';
import { Schema } from './schema';
Expand Down
Expand Up @@ -5,7 +5,7 @@ import {
ngrxVersion,
rxjsVersion as defaultRxjsVersion,
} from '../../../utils/versions';
import { checkAndCleanWithSemver } from '@nrwl/workspace';
import { checkAndCleanWithSemver } from '@nrwl/workspace/src/utilities/version-utils';

export function addNgRxToPackageJson(tree: Tree): GeneratorCallback {
let rxjsVersion: string;
Expand Down
@@ -1,5 +1,5 @@
import { readJson, Tree } from '@nrwl/devkit';
import { checkAndCleanWithSemver } from '@nrwl/workspace';
import { checkAndCleanWithSemver } from '@nrwl/workspace/src/utilities/version-utils';
import { lt } from 'semver';

export function detectTailwindInstalledVersion(
Expand Down
8 changes: 4 additions & 4 deletions packages/angular/src/utils/mfe-webpack.spec.ts
@@ -1,7 +1,7 @@
jest.mock('fs');
jest.mock('@nrwl/workspace');
jest.mock('@nrwl/workspace/src/utilities/typescript');
import * as fs from 'fs';
import * as workspace from '@nrwl/workspace';
import * as tsUtils from '@nrwl/workspace/src/utilities/typescript';

import { sharePackages, shareWorkspaceLibraries } from './mfe-webpack';

Expand All @@ -27,7 +27,7 @@ describe('MFE Webpack Utils', () => {
it('should create an object with correct setup', () => {
// ARRANGE
(fs.existsSync as jest.Mock).mockReturnValue(true);
(workspace.readTsConfig as jest.Mock).mockReturnValue({
(tsUtils.readTsConfig as jest.Mock).mockReturnValue({
options: {
paths: {
'@myorg/shared': ['/libs/shared/src/index.ts'],
Expand All @@ -53,7 +53,7 @@ describe('MFE Webpack Utils', () => {
it('should create an object with empty setup when tsconfig does not contain the shared lib', () => {
// ARRANGE
(fs.existsSync as jest.Mock).mockReturnValue(true);
(workspace.readTsConfig as jest.Mock).mockReturnValue({
(tsUtils.readTsConfig as jest.Mock).mockReturnValue({
options: {
paths: {},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/utils/mfe-webpack.ts
@@ -1,4 +1,4 @@
import { readTsConfig } from '@nrwl/workspace';
import { readTsConfig } from '@nrwl/workspace/src/utilities/typescript';
import { existsSync, readFileSync } from 'fs';
import { NormalModuleReplacementPlugin } from 'webpack';
import { appRootPath as rootPath } from 'nx/src/utils/app-root';
Expand Down

0 comments on commit 7ae6d48

Please sign in to comment.