Skip to content

Commit

Permalink
chore: rename variables for readable
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Aug 20, 2021
1 parent 98a4567 commit 7d1ded1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/scripts/dev_tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { sendMessage } from "webext-bridge";
import { SecretLintMessage } from "./types";
import { SettingSchema } from "./settings/SettingSchema";
import { SCHEMA } from "./settings/SettingSchema.validator";
import { ALLOWS } from "./secretlint/rule.allows";
import { RULES_DEFAULT_ALLOWS } from "./secretlint/rule.allows";

const headersToEnv = (headers: Request["headers"]): string => {
return headers
Expand Down Expand Up @@ -53,7 +53,7 @@ const lintContentAndSend = async ({
sliceBefore: SCHEMA.definitions.SettingSchema.properties.sliceBefore.default,
sliceAfter: SCHEMA.definitions.SettingSchema.properties.sliceAfter.default,
enableConsoleIntegration: SCHEMA.definitions.SettingSchema.properties.enableConsoleIntegration.default,
allows: storage["rule.allows"] ?? ALLOWS,
allows: storage["rule.allows"] ?? RULES_DEFAULT_ALLOWS,
...storage?.settings
} as SettingSchema & {
allows: string[];
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/secretlint/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { lintSource } from "@secretlint/core";
// @ts-ignore
import { rules } from "@secretlint/secretlint-rule-preset-recommend";
import pattern from "@secretlint/secretlint-rule-pattern";
import { PATTERNS } from "./rule.patterns";
import { RULE_DEFAULT_PATTERNS } from "./rule.patterns";

/**
* HeaderName=HeaderValue
Expand Down Expand Up @@ -34,7 +34,7 @@ export const lintContent = ({ content, url, allows }: { content: string; url: st
rule: pattern,
options: {
// based on https://github.com/l4yton/RegHex
patterns: PATTERNS,
patterns: RULE_DEFAULT_PATTERNS,
allows
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/secretlint/rule.allows.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const ALLOWS = [
export const RULES_DEFAULT_ALLOWS = [
// local ip
"0.0.0.0",
"1.1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/secretlint/rule.patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* pattern: string or regexp-like string(/pattern/)
*
*/
export const PATTERNS = [
export const RULE_DEFAULT_PATTERNS = [
{
name: "Artifactory API Token",
pattern: '/(?:\\s|=|:|"|^)AKC[a-zA-Z0-9]{10,}/'
Expand Down
8 changes: 4 additions & 4 deletions app/scripts/settings/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import React, { useCallback, useEffect, useState } from "react";
import { SCHEMA } from "./SettingSchema.validator";
import { browser } from "webextension-polyfill-ts";
import { SettingSchema } from "./SettingSchema";
import { PATTERNS } from "../secretlint/rule.patterns";
import { RULE_DEFAULT_PATTERNS } from "../secretlint/rule.patterns";
import { CodeEditor } from "./CodeEditor";
import { ALLOWS } from "../secretlint/rule.allows";
import { RULES_DEFAULT_ALLOWS } from "../secretlint/rule.allows";

const useStorageLocal = <V extends any>(name: string, initialValue?: V) => {
const [state, setState] = useState<V | undefined>(initialValue);
Expand Down Expand Up @@ -36,8 +36,8 @@ type Pattern = { name: string; pattern: string };
type Patterns = Pattern[];
export const useApp = () => {
const [settings, setSettings] = useStorageLocal<Partial<SettingSchema>>("settings");
const [patterns, setPatterns] = useStorageLocal<Patterns>("rule.patterns", PATTERNS);
const [allows, setAllows] = useStorageLocal<string[]>("rule.allows", ALLOWS);
const [patterns, setPatterns] = useStorageLocal<Patterns>("rule.patterns", RULE_DEFAULT_PATTERNS);
const [allows, setAllows] = useStorageLocal<string[]>("rule.allows", RULES_DEFAULT_ALLOWS);
const [patternValue, setPatternValue] = useState(JSON.stringify(patterns, null, 2));
const [allowsValue, setAllowsValue] = useState(JSON.stringify(allows, null, 2));
useEffect(() => {
Expand Down

0 comments on commit 7d1ded1

Please sign in to comment.