🚨(lint) update file for prettier 3.0.0

Prettier 3.0.0 comes with new standards so we need to upgrade our files
to comply with it.
This commit is contained in:
Nathan Vasse
2023-07-18 15:43:56 +02:00
committed by NathanVss
parent 5f63c2a606
commit d85f9edac8
61 changed files with 421 additions and 419 deletions

View File

@@ -31,11 +31,11 @@ describe("CssGenerator", () => {
"..",
"tests",
"assets",
"expected-default-" + Config.tokenFilename + ".css"
)
"expected-default-" + Config.tokenFilename + ".css",
),
)
.toString()
.replace(":root", "html")
.replace(":root", "html"),
);
};
@@ -58,11 +58,11 @@ describe("CssGenerator", () => {
"..",
"tests",
"assets",
"expected-with-utility-classes-" + Config.tokenFilename + ".css"
)
"expected-with-utility-classes-" + Config.tokenFilename + ".css",
),
)
.toString()
.replace(":root", "html")
.replace(":root", "html"),
);
});
});

View File

@@ -52,7 +52,7 @@ function generateColorClasses(tokens: Tokens) {
function generateBgClasses(tokens: Tokens) {
return Object.keys(tokens.theme.colors).map(
(key) =>
`.bg-${key} { background-color: var(--${Config.sass.varPrefix}theme--colors--${key}); }`
`.bg-${key} { background-color: var(--${Config.sass.varPrefix}theme--colors--${key}); }`,
);
}
@@ -65,7 +65,7 @@ function generateBgClasses(tokens: Tokens) {
function generateClrClasses(tokens: Tokens) {
return Object.keys(tokens.theme.colors).map(
(key) =>
`.clr-${key} { color: var(--${Config.sass.varPrefix}theme--colors--${key}); }`
`.clr-${key} { color: var(--${Config.sass.varPrefix}theme--colors--${key}); }`,
);
}
@@ -86,7 +86,7 @@ function generateFontClasses(tokens: Tokens) {
function generateFwClasses(tokens: Tokens) {
return Object.keys(tokens.theme.font.weights).map(
(key) =>
`.fw-${key} { font-weight: var(--${Config.sass.varPrefix}theme--font--weights--${key}); }`
`.fw-${key} { font-weight: var(--${Config.sass.varPrefix}theme--font--weights--${key}); }`,
);
}
@@ -99,7 +99,7 @@ function generateFwClasses(tokens: Tokens) {
function generateFsClasses(tokens: Tokens) {
return Object.keys(tokens.theme.font.sizes).map(
(key) =>
`.fs-${key} { font-size: var(--${Config.sass.varPrefix}theme--font--sizes--${key}); }`
`.fs-${key} { font-size: var(--${Config.sass.varPrefix}theme--font--sizes--${key}); }`,
);
}
@@ -112,7 +112,7 @@ function generateFsClasses(tokens: Tokens) {
function generateFClasses(tokens: Tokens) {
return Object.keys(tokens.theme.font.families).map(
(key) =>
`.f-${key} { font-family: var(--${Config.sass.varPrefix}theme--font--families--${key}); }`
`.f-${key} { font-family: var(--${Config.sass.varPrefix}theme--font--families--${key}); }`,
);
}
@@ -133,7 +133,7 @@ function generateMarginClasses(tokens: Tokens) {
`.mb-${key} { margin-bottom: var(--${Config.sass.varPrefix}theme--spacings--${key}); }` +
`.mt-${key} { margin-top: var(--${Config.sass.varPrefix}theme--spacings--${key}); }` +
`.ml-${key} { margin-left: var(--${Config.sass.varPrefix}theme--spacings--${key}); }` +
`.mr-${key} { margin-right: var(--${Config.sass.varPrefix}theme--spacings--${key}); }`
`.mr-${key} { margin-right: var(--${Config.sass.varPrefix}theme--spacings--${key}); }`,
);
}
@@ -150,6 +150,6 @@ function generatePaddingClasses(tokens: Tokens) {
`.pb-${key} { padding-bottom: var(--${Config.sass.varPrefix}theme--spacings--${key}); }` +
`.pt-${key} { padding-top: var(--${Config.sass.varPrefix}theme--spacings--${key}); }` +
`.pl-${key} { padding-left: var(--${Config.sass.varPrefix}theme--spacings--${key}); }` +
`.pr-${key} { padding-right: var(--${Config.sass.varPrefix}theme--spacings--${key}); }`
`.pr-${key} { padding-right: var(--${Config.sass.varPrefix}theme--spacings--${key}); }`,
);
}

View File

@@ -35,7 +35,7 @@ function JSONToSassMap(json: Object, isDefault = true) {
[`'${key}'`]:
typeof value === "object" ? deepQuoteObjectKeys(value) : value,
}),
{}
{},
);
}
const jsonWithQuotedKeys = deepQuoteObjectKeys(json);

View File

@@ -12,7 +12,7 @@ describe("resolveRefs", () => {
tokens as unknown as Tokens,
(ref, resolvingTokens) => {
return resolve(resolvingTokens, ref);
}
},
);
expect(res).toEqual({
a: "b",
@@ -51,7 +51,7 @@ describe("resolveRefs", () => {
tokens as unknown as Tokens,
(ref, resolvingTokens) => {
return resolve(resolvingTokens, ref);
}
},
);
expect(res).toEqual({
a: "b",
@@ -77,7 +77,7 @@ describe("resolveRefs", () => {
tokens as unknown as Tokens,
(ref, resolvingTokens) => {
return resolve(resolvingTokens, ref);
}
},
);
expect(res).toEqual({
a: "value",
@@ -97,7 +97,7 @@ describe("resolveRefs", () => {
return `ref(${ref})`;
});
}).toThrow(
"Maximum resolveRefs iterations: please reduce usage of chained references."
"Maximum resolveRefs iterations: please reduce usage of chained references.",
);
});
});

View File

@@ -7,7 +7,7 @@ import { resolve } from "Utils/resolve";
export type Generator = (
tokens: Tokens,
opts: { path: string; selector: string; utilityClasses?: boolean }
opts: { path: string; selector: string; utilityClasses?: boolean },
) => Promise<void>;
export const Generators: Record<string, Generator> = {
@@ -19,7 +19,7 @@ export const Generators: Record<string, Generator> = {
export const resolveRefs = (
tokens: Tokens,
callback: (ref: string, tokens: Tokens) => string
callback: (ref: string, tokens: Tokens) => string,
): Tokens => {
let refsCount = 0;
let resolved = tokens;
@@ -72,7 +72,7 @@ export const resolveRefs = (
// Prevent infinite loops.
if (iterations >= maxIterations) {
throw new Error(
"Maximum resolveRefs iterations: please reduce usage of chained references."
"Maximum resolveRefs iterations: please reduce usage of chained references.",
);
}
refsCount = 0;

View File

@@ -22,13 +22,13 @@ export const buildTheme = async () => {
selector: options.selector,
utilityClasses: options.utilityClasses,
});
})
}),
);
};
export const run = async (args: string[]) => {
console.log(
chalk.red(figlet.textSync("Cunningham", { horizontalLayout: "full" }))
chalk.red(figlet.textSync("Cunningham", { horizontalLayout: "full" })),
);
const commaSeparatedList = (value: string) => {
@@ -40,21 +40,21 @@ export const run = async (args: string[]) => {
.option(
"-s, --selector <selector>",
"Specify the css root selector element.",
":root"
":root",
)
.option(
"-cwd, --working-dir <directory>",
"Specify the working dir ( you might not need this )."
"Specify the working dir ( you might not need this ).",
)
.option(
"-o, --output <directory>",
"Specify the output dir of generated files."
"Specify the output dir of generated files.",
)
.option("--utility-classes", "Generate CSS utility classes.")
.requiredOption(
"-g, --generators <generators>",
"Specify the generators to use.",
commaSeparatedList
commaSeparatedList,
)
.parse(args);

View File

@@ -14,6 +14,6 @@ export const put = (path: string, content: string) => {
fs.writeFileSync(path, content);
console.log(
chalk.bgGreen(chalk.white("File " + path + " generated successfully."))
chalk.bgGreen(chalk.white("File " + path + " generated successfully.")),
);
};

View File

@@ -1,7 +1,7 @@
export const resolve = (
object: Record<string, any>,
path: string,
separator: string = "."
separator: string = ".",
): any => {
return path.split(separator).reduce((acc, cur) => {
return acc[cur];

View File

@@ -16,7 +16,7 @@ const runBin = async (args: string) => {
const promise = exec(
path.join(__dirname, "..", "..", "..", "dist", "bin", "Main.js") +
" " +
args
args,
);
promise.child.stdout?.on("data", (data) => {
@@ -61,10 +61,10 @@ describe("Cunningham Bin", () => {
path.join(
__dirname,
"assets",
"expected-default-" + Config.tokenFilename + ".css"
)
"expected-default-" + Config.tokenFilename + ".css",
),
)
.toString()
.toString(),
);
});
@@ -77,7 +77,7 @@ describe("Cunningham Bin", () => {
fs.copyFileSync(
path.join(__dirname, "assets", "cunningham.js"),
localConfigurationFile
localConfigurationFile,
);
expect(fs.existsSync(localConfigurationFile)).toEqual(true);
@@ -89,10 +89,10 @@ describe("Cunningham Bin", () => {
path.join(
__dirname,
"assets",
"expected-js-" + Config.tokenFilename + ".css"
)
"expected-js-" + Config.tokenFilename + ".css",
),
)
.toString()
.toString(),
);
});
@@ -105,7 +105,7 @@ describe("Cunningham Bin", () => {
fs.copyFileSync(
path.join(__dirname, "assets", "cunningham.ts"),
localConfigurationFile
localConfigurationFile,
);
expect(fs.existsSync(localConfigurationFile)).toEqual(true);
@@ -131,10 +131,10 @@ describe("Cunningham Bin", () => {
path.join(
__dirname,
"assets",
"expected-default-" + Config.tokenFilename + ".css"
)
"expected-default-" + Config.tokenFilename + ".css",
),
)
.toString()
.toString(),
);
};

View File

@@ -9,7 +9,7 @@ import { Generators } from "Generators";
*/
export const cleanup = (dir: string) => {
const tokenFilenames = Object.keys(Generators).map(
(extension) => Config.tokenFilename + "." + extension
(extension) => Config.tokenFilename + "." + extension,
);
tokenFilenames.forEach((filename) => {