Skip to content

Commit

Permalink
cleanup(misc): use more es6 features
Browse files Browse the repository at this point in the history
- Single char alternation (e.g. a|b|c|d) in a RegExp can be simplified to use a character class ([abcd]) instead.
  This usually also provides slightly better matching performance.
- Character escapes that are replaceable with the unescaped character without a change in meaning. Inside the square brackets of a character class, many escapes are unnecessary that would be necessary outside of a character class. For example the regex [\.] is identical to [.]
- If several qualified expressions occur after the qualifier having been checked for nullable, they can be replaced with optional chaining
  • Loading branch information
vivekmore authored and vsavkin committed Mar 25, 2021
1 parent 4b669f2 commit 212fb00
Show file tree
Hide file tree
Showing 64 changed files with 95 additions and 113 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ We would love for you to contribute to Nx! Read this document to see how to do i
Watch this 5-minute video:

<a href="https://www.youtube.com/watch?v=o11p0zSm0No&feature=youtu.be" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/how-to-contribute.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/how-to-contribute.png" width="600"></p>
</a>

## Got a Question?
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>

<div align="center">
<div style="text-align: center;">

[![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
[![License](https://img.shields.io/npm/l/@nrwl/workspace.svg?style=flat-square)]()
Expand Down Expand Up @@ -103,12 +103,12 @@ You are good to go!
<tr>
<td>
<a href="https://www.youtube.com/watch?v=mVKMse-gFBI" target="_blank">
<p align="center">Angular<br><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-angular-video.png" width="350"></p>
<p style="text-align: center;">Angular<br><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-angular-video.png" width="350"></p>
</a>
</td>
<td>
<a href="https://www.youtube.com/watch?v=E188J7E_MDU" target="_blank">
<p align="center">React<br><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p>
<p style="text-align: center;">React<br><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p>
</a>
</td>
</tr>
Expand All @@ -125,17 +125,17 @@ You are good to go!
<tr>
<td>
<a href="https://egghead.io/playlists/scale-react-development-with-nx-4038" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/EGH_ScalingReactNx.png" height="150px"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/EGH_ScalingReactNx.png" height="150px"></p>
</a>
</td>
<td>
<a href="https://www.youtube.com/watch?v=2mYLe9Kp9VM&list=PLakNactNC1dH38AfqmwabvOszDmKriGco" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-workspace-course.png" width="350"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-workspace-course.png" width="350"></p>
</a>
</td>
<td>
<a href="https://nxplaybook.com/p/advanced-nx-workspaces" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/advanced-nx-workspace-course.png" width="350"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/advanced-nx-workspace-course.png" width="350"></p>
</a>
</td>
</tr>
Expand Down Expand Up @@ -193,7 +193,7 @@ You are good to go!
If you want to file a bug or submit a PR, read up on our [guidelines for contributing](https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md) and watch this video that will help you get started.

<a href="https://www.youtube.com/watch?v=o11p0zSm0No&feature=youtu.be" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/how-to-contribute.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/how-to-contribute.png" width="600"></p>
</a>

## Core Team
Expand Down
2 changes: 1 addition & 1 deletion apps/dep-graph-client/src/app/util-cytoscape/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ProjectEdge {
target: this.dep.target,
},
};
edge.classes = this.dep.type ? this.dep.type : '';
edge.classes = this.dep.type ?? '';
if (this.affected) {
edge.classes += ' affected';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class ProjectNode {
}

private getClasses(): string {
let classes = this.project.type ? this.project.type : '';
let classes = this.project.type ?? '';

if (this.focused) {
classes += ' focused';
Expand Down
6 changes: 2 additions & 4 deletions apps/dep-graph-client/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,11 @@ h5 {
}

.sidebar {
min-width: 200px;
min-width: 260px;
max-width: calc(50% - 10px);
z-index: 1;
position: relative;
height: 100%;
min-width: 260px;
box-shadow: 2px 0 2px rgba(51, 51, 51, 0.1);
}

Expand Down Expand Up @@ -176,13 +175,12 @@ html {
}

.tag {
padding: 0.4rem;
padding: 0.5rem;
font-size: 0.75em;
display: inline-block;
border: 1px solid var(--color-nrwl-light-blue);
text-transform: uppercase;
color: var(--color-grey);
padding: 0.5rem;
line-height: 1;
letter-spacing: 0.5px;
margin-right: 0.4em;
Expand Down
24 changes: 11 additions & 13 deletions e2e/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { detectPackageManager } from '@nrwl/tao/src/shared/package-manager';
import { ChildProcess, exec, execSync } from 'child_process';
import {
copySync,
createFileSync,
ensureDirSync,
moveSync,
readdirSync,
readFileSync,
removeSync,
renameSync,
statSync,
writeFileSync,
ensureDirSync,
createFileSync,
moveSync,
copySync,
removeSync,
} from 'fs-extra';
import * as path from 'path';
import { detectPackageManager } from '@nrwl/tao/src/shared/package-manager';
import * as isCI from 'is-ci';
import * as path from 'path';

interface RunCmdOpts {
silenceError?: boolean;
Expand All @@ -23,7 +23,7 @@ interface RunCmdOpts {
}

export function currentCli() {
return process.env.SELECTED_CLI ? process.env.SELECTED_CLI : 'nx';
return process.env.SELECTED_CLI ?? 'nx';
}

let projName: string;
Expand Down Expand Up @@ -359,16 +359,14 @@ function setMaxWorkers() {
const workspace = readJson(workspaceFile);

Object.keys(workspace.projects).forEach((appName) => {
const targets = workspace.projects[appName].targets
? workspace.projects[appName].targets
: workspace.projects[appName].architect;
const build = targets.build;
const project = workspace.projects[appName];
const { build } = project.targets ?? project.architect;

if (!build) {
return;
}

const executor = build.builder ? build.builder : build.executor;
const executor = build.builder ?? build.executor;
if (
executor.startsWith('@nrwl/node') ||
executor.startsWith('@nrwl/web') ||
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>

{{links}}

Expand Down Expand Up @@ -36,7 +36,7 @@ You can always add the Angular plugin to an existing workspace by installing `@n
## Quick Start Videos

<a href="https://www.youtube.com/watch?v=mVKMse-gFBI" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-angular-video.png" width="350"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-angular-video.png" width="350"></p>
</a>

- [Nx Dev Tools for Monorepos, In-Depth Explainer](https://youtu.be/h5FIGDn5YM0)
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/schematics/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ function normalizeOptions(host: Tree, options: Schema): NormalizedSchema {
const defaultPrefix = getNpmScope(host);
return {
...options,
prefix: options.prefix ? options.prefix : defaultPrefix,
prefix: options.prefix ?? defaultPrefix,
name: appProjectName,
appProjectRoot,
e2eProjectRoot,
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/schematics/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"index": 0
},
"x-prompt": "What name would you like to use for the application?",
"pattern": "^[a-zA-Z]{1}.*$"
"pattern": "^[a-zA-Z].*$"
},
"directory": {
"description": "The directory of the new application.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ function addEntryComponentsToModule(options: Schema): Rule {
}

export default function (options: Schema): Rule {
const angularJsImport = options.angularJsImport
? options.angularJsImport
: options.name;
const angularJsImport = options.angularJsImport ?? options.name;

return chain([
updateMain(angularJsImport, options),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function normalizeOptions(

return {
...options,
prefix: options.prefix ? options.prefix : defaultPrefix,
prefix: options.prefix ?? defaultPrefix,
name: projectName,
projectRoot,
entryFile: 'index',
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/schematics/library/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"index": 0
},
"x-prompt": "What name would you like to use for the library?",
"pattern": "^[a-zA-Z]{1}.*$"
"pattern": "^[a-zA-Z].*$"
},
"directory": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ function createFiles(angularJsImport: string, options: Schema): Rule {
}

export default function (options: Schema): Rule {
const angularJsImport = options.angularJsImport
? options.angularJsImport
: options.name;
const angularJsImport = options.angularJsImport ?? options.name;

return chain([
createFiles(angularJsImport, options),
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>

{{links}}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/parse-run-one-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function parseRunOneOptions(
workspaceConfigJson.projects && workspaceConfigJson.projects[project];
if (!p) return false;

const targets = p.architect ? p.architect : p.targets;
const targets = p.architect ?? p.targets;
// for backwards compat we require targets to be set when use defaultProjectName
if ((!targets || !targets[target]) && projectIsNotSetExplicitly) return false;
if (invalidTargetNames.indexOf(target) > -1) return false;
Expand Down
2 changes: 1 addition & 1 deletion packages/create-nx-plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>

{{links}}

Expand Down
2 changes: 1 addition & 1 deletion packages/create-nx-workspace/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>

{{links}}

Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>

{{links}}

Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/src/plugins/preprocessor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('getWebpackConfig', () => {
},
});
expect(config.module.rules).toContainEqual({
test: /\.(j|t)sx?$/,
test: /\.([jt])sx?$/,
loader: require.resolve('ts-loader'),
exclude: [/node_modules/],
options: {
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/src/plugins/preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function getWebpackConfig(config: any) {
module: {
rules: [
{
test: /\.(j|t)sx?$/,
test: /\.([jt])sx?$/,
loader: require.resolve('ts-loader'),
exclude: [/node_modules/],
options: {
Expand Down
2 changes: 1 addition & 1 deletion packages/devkit/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>

{{links}}

Expand Down
4 changes: 1 addition & 3 deletions packages/devkit/src/utils/get-workspace-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ export function getWorkspaceLayout(
host: Tree
): { appsDir: string; libsDir: string; npmScope: string } {
const nxJson = readJson<NxJsonConfiguration>(host, 'nx.json');
const layout = nxJson.workspaceLayout
? nxJson.workspaceLayout
: { appsDir: 'apps', libsDir: 'libs' };
const layout = nxJson.workspaceLayout ?? { appsDir: 'apps', libsDir: 'libs' };
const npmScope = nxJson.npmScope;
return { ...layout, npmScope };
}
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-nx/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>

{{links}}

Expand Down
2 changes: 1 addition & 1 deletion packages/express/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>

{{links}}

Expand Down
2 changes: 1 addition & 1 deletion packages/express/src/schematics/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"index": 0
},
"x-prompt": "What name would you like to use for the node application?",
"pattern": "^[a-zA-Z]{1}.*$"
"pattern": "^[a-zA-Z].*$"
},
"directory": {
"description": "The directory of the new application.",
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-gatsby.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-gatsby.png" width="600"></p>

{{links}}

Expand Down Expand Up @@ -32,7 +32,7 @@ You are good to go!
## Quick Start Videos

<a href="https://www.youtube.com/watch?v=E188J7E_MDU" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p>
</a>

- [Nx Dev Tools for Monorepos, In-Depth Explainer (React)](https://www.youtube.com/watch?v=jCf92IyR-GE)
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/generators/application/files/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- AUTO-GENERATED-CONTENT:START (STARTER) -->
<p align="center">
<p style="text-align: center;">
<a href="https://www.gatsbyjs.org">
<img alt="Gatsby" src="https://www.gatsbyjs.org/monogram.svg" width="60" />
</a>
Expand Down
2 changes: 1 addition & 1 deletion packages/jest/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>

{{links}}

Expand Down
2 changes: 1 addition & 1 deletion packages/linter/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>

{{links}}

Expand Down
2 changes: 1 addition & 1 deletion packages/nest/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Powerful, Extensible Dev Tools"></p>

{{links}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function normalizeOptions(
name,
path: options.path,
sourceRoot,
spec: options.spec ? options.spec : options.unitTestRunner === 'jest',
spec: options.spec ?? options.unitTestRunner === 'jest',
};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/next/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-next.png" width="600"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-next.png" width="600"></p>

{{links}}

Expand Down Expand Up @@ -32,7 +32,7 @@ You are good to go!
## Quick Start Videos

<a href="https://www.youtube.com/watch?v=E188J7E_MDU" target="_blank">
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p>
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-react-video.png" width="350"></p>
</a>

- [Nx Dev Tools for Monorepos, In-Depth Explainer (React)](https://www.youtube.com/watch?v=jCf92IyR-GE)
Expand Down
Loading

0 comments on commit 212fb00

Please sign in to comment.