Skip to content

Commit

Permalink
fix(eslint): Fix eslint warnings for no-useless-escape
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Feb 14, 2019
1 parent 7692c2e commit ddbe208
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const helpContents = [
},
{
key: 'appengine.serverGroup.stopPreviousVersion',
value: `If selected, the previously running server group in this server group\'s <b>service</b>
value: `If selected, the previously running server group in this server group's <b>service</b>
(Spinnaker load balancer) will be stopped. This option will be respected only if this server group will
be receiving all traffic and the previous server group is using manual scaling.`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class CloudFoundryServerGroupConfigurationSettings
}
if (values.manifest.routes) {
const routeErrors = values.manifest.routes.map((route: string) => {
const regex = /^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_.-]+)(:[0-9]+)?([\/a-zA-Z0-9_-]+)?$/gm;
const regex = /^([-\w]+)\.([-.\w]+)(:\d+)?([-/\w]+)?$/gm;
if (route && regex.exec(route) === null) {
return `A route did not match the expected format "host.some.domain[:9999][/some/path]"`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class NumberListComponent implements IComponentOptions {
ng-class="{active: !$ctrl.parameterized}"
ng-click="$ctrl.toggleParameterization(true)"
uib-tooltip="Toggle to enter expression">
$\{…\}
$\{…}
</button>
</div>
<div ng-if="!$ctrl.parameterized" class="row-number" ng-repeat="entry in $ctrl.backingModel track by $index">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export class CreatePipelineModal extends React.Component<ICreatePipelineModalPro
};

public validateNameCharacters(): boolean {
return /^[^\\\^/^?^%^#]*$/.test(this.state.command.name); // Verify name does not include: \, ^, ?, %, #
return /^[^\\^/?%#]*$/.test(this.state.command.name); // Verify name does not include: \, ^, ?, %, #
}

public validateNameIsUnique(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export class ProjectAttributes extends React.Component<IProjectAttributesProps,
const errors: FormikErrors<IProject> = {};

const isValidName = (name: string) => {
const namePattern = /^[^\\\^/^?^%^#]*$/;
const namePattern = /^[^\\^/?%#]*$/;
return name.match(namePattern);
};

const isValidEmail = (email: string) => {
const emailPattern = /^(.+)\@(.+).([A-Za-z]{2,6})/;
const emailPattern = /^(.+)@(.+).([A-Za-z]{2,6})/;
return email.match(emailPattern);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class JsonListBuilder {
}

public static escapeForRegEx(item: string): string {
// eslint-disable-next-line no-useless-escape
return item ? item.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&') : null;
}

Expand All @@ -43,7 +44,7 @@ export class JsonListBuilder {
if (!(isObject(value) || Array.isArray(value))) {
if (
!ignoreList.some(ignoreItem => {
const testerString = `[\'${ignoreItem}`;
const testerString = `['${ignoreItem}`;
return entry.substr(0, testerString.length) === testerString;
})
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class GceDiskConfigurer implements IComponentOptions {
This disk will use the image selected at the top of this dialogue.
</p>
<p class="small" style="margin: 0;" ng-if="$ctrl.command.viewState.mode === 'createPipeline' || $ctrl.command.viewState.mode === 'editPipeline'">
This disk will use the image inferred from this pipeline\'s execution context.
This disk will use the image inferred from this pipeline's execution context.
</p>
</div>
<ui-select ng-if="$index > 0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ import { DockerImageAndTagSelector, DockerImageUtils } from '@spinnaker/docker';
import { ITitusServerGroupCommand } from '../../../configure/serverGroupConfiguration.service';

const isNotExpressionLanguage = (field: string) => field && !field.includes('${');
const isStackPattern = (stack: string) =>
isNotExpressionLanguage(stack) ? /^([a-zA-Z_0-9._${}]*(\${.+})*)*$/.test(stack) : true;

// Allow dot, underscore, and spel
const isStackPattern = (stack: string) => (isNotExpressionLanguage(stack) ? /^([\w.]+|\${[^}]+})*$/.test(stack) : true);

// Allow dot, underscore, caret, tilde, dash and spel
const isDetailPattern = (detail: string) =>
isNotExpressionLanguage(detail) ? /^([a-zA-Z_0-9._$-{}\\\^~]*(\${.+})*)*$/.test(detail) : true;
isNotExpressionLanguage(detail) ? /^([\w.^~-]+|\${[^}]+})*$/.test(detail) : true;

export interface IServerGroupBasicSettingsProps {
app: Application;
Expand Down

0 comments on commit ddbe208

Please sign in to comment.