Skip to content

Commit 75be87d

Browse files
fix: remove eslint-plugin-prettier
1 parent 6e47d39 commit 75be87d

8 files changed

+49
-114
lines changed

.eslintrc.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
{
22
"extends": [
33
"xo",
4-
"prettier",
54
"eslint:recommended",
6-
"plugin:@typescript-eslint/recommended"
5+
"plugin:@typescript-eslint/recommended",
6+
"prettier"
77
],
88
"env": {
99
"jest": true,
1010
"node": true
1111
},
1212
"rules": {
13-
"prettier/prettier": "error",
1413
"complexity": "off",
1514
"@typescript-eslint/no-namespace": "off",
1615
"no-warning-comments": "off",
@@ -25,6 +24,6 @@
2524
}
2625
]
2726
},
28-
"plugins": ["prettier", "@typescript-eslint"],
27+
"plugins": ["@typescript-eslint"],
2928
"parser": "@typescript-eslint/parser"
3029
}

lib/__tests__/css-helper.test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe("css-help", () => {
2828
});
2929
it("should return a whitespaceless string", () => {
3030
expect(t.getStyle(".bb1d")?.getPropVal("background", true)).toEqual(
31-
"linear-gradient(var(--building-color1)50%,var(--window-color1))"
31+
"linear-gradient(var(--building-color1)50%,var(--window-color1))",
3232
);
3333
});
3434
});
@@ -56,22 +56,22 @@ describe("css-help", () => {
5656
describe("getPropertyValue", () => {
5757
it("should return custom property value needing trim", () => {
5858
expect(
59-
t.getStyle(":root")?.getPropertyValue("--building-color1")?.trim()
59+
t.getStyle(":root")?.getPropertyValue("--building-color1")?.trim(),
6060
).toEqual("#aa80ff");
6161
});
6262
it("should return value to existing property", () => {
6363
expect(
64-
t.getStyle(".bb4a")?.getPropertyValue("background-color")
64+
t.getStyle(".bb4a")?.getPropertyValue("background-color"),
6565
).toBeTruthy();
6666
});
6767
it("should return property value without evaluating result", () => {
6868
expect(t.getStyle(".bb4a")?.getPropertyValue("background-color")).toEqual(
69-
"var(--building-color4)"
69+
"var(--building-color4)",
7070
);
7171
});
7272
it("should return value of pseudo class selector", () => {
7373
expect(
74-
t.getStyle(".card:hover")?.getPropertyValue("background-color")
74+
t.getStyle(".card:hover")?.getPropertyValue("background-color"),
7575
).toEqual("khaki");
7676
});
7777
});
@@ -85,23 +85,23 @@ describe("css-help", () => {
8585
expect(
8686
t
8787
.getRuleListsWithinMedia("(max-width: 1000px)")
88-
.find((x) => x.selectorText === ".sky")
88+
.find((x) => x.selectorText === ".sky"),
8989
).toBeTruthy();
9090
});
9191
it("should return CSSStyleDeclaration property with complex value", () => {
9292
// NOTE: JSDOM causes value to have tabbed characters, DOM has single-line values.
9393
expect(
9494
t
9595
.getRuleListsWithinMedia("(max-width: 1000px)")
96-
.find((x) => x.selectorText === ".sky")?.style?.background
96+
.find((x) => x.selectorText === ".sky")?.style?.background,
9797
).toEqual(
9898
`radial-gradient(
9999
closest-corner circle at 15% 15%,
100100
#ffcf33,
101101
#ffcf33 20%,
102102
#ffff66 21%,
103103
#bbeeff 100%
104-
)`
104+
)`,
105105
);
106106
});
107107
});

lib/__tests__/curriculum-helper.test.tsx

+15-15
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ describe("removeWhiteSpace", () => {
7474
const { removeWhiteSpace } = helper;
7575
it("returns a string", () => {
7676
expect(typeof removeWhiteSpace("This should return a string")).toBe(
77-
"string"
77+
"string",
7878
);
7979
});
8080

8181
it("returns a string with no white space characters", () => {
8282
expect(removeWhiteSpace(stringWithWhiteSpaceChars)).toBe(
83-
stringWithWhiteSpaceCharsRemoved
83+
stringWithWhiteSpaceCharsRemoved,
8484
);
8585
});
8686
});
@@ -89,13 +89,13 @@ describe("removeJSComments", () => {
8989
const { removeJSComments } = helper;
9090
it("returns a string", () => {
9191
expect(typeof removeJSComments('const should = "return a string"')).toBe(
92-
"string"
92+
"string",
9393
);
9494
});
9595

9696
it("returns a string with no single or multi-line comments", () => {
9797
expect(removeJSComments(jsCodeWithSingleAndMultLineComments)).toBe(
98-
jsCodeWithSingleAndMultLineCommentsRemoved
98+
jsCodeWithSingleAndMultLineCommentsRemoved,
9999
);
100100
});
101101

@@ -125,14 +125,14 @@ describe("removeHtmlComments", () => {
125125
it("returns a string", () => {
126126
expect(
127127
typeof removeHtmlComments(
128-
"<h1>hello world</h1><!-- a comment--><h2>h2 element</h2>"
129-
)
128+
"<h1>hello world</h1><!-- a comment--><h2>h2 element</h2>",
129+
),
130130
).toBe("string");
131131
});
132132

133133
it("returns an HTML string with no single or multi-line comments", () => {
134134
expect(removeHtmlComments(htmlFullExample)).toBe(
135-
htmlCodeWithCommentsRemoved
135+
htmlCodeWithCommentsRemoved,
136136
);
137137
});
138138
});
@@ -199,7 +199,7 @@ describe("functionRegex", () => {
199199
const funcName = "myFunc";
200200
const regEx = functionRegex(funcName, ["arg1", "arg2"]);
201201
expect(regEx.test("function myFunc(arg1, arg2){\n console.log()\n}")).toBe(
202-
true
202+
true,
203203
);
204204
});
205205

@@ -248,7 +248,7 @@ describe("functionRegex", () => {
248248
const funcName = "myFunc";
249249
const regEx = functionRegex(funcName, ["arg1", "arg2"]);
250250
expect(regEx.test("function \n\n myFunc \n ( arg1 , arg2 ) \n{ }")).toBe(
251-
true
251+
true,
252252
);
253253
});
254254

@@ -258,7 +258,7 @@ describe("functionRegex", () => {
258258
const combinedRegEx = helper.concatRegex(/var x = 'y'; /, regEx);
259259

260260
const match = "var x = 'y'; function myFunc(arg1, arg2){}".match(
261-
combinedRegEx
261+
combinedRegEx,
262262
);
263263
expect(match).not.toBeNull();
264264
expect(match![0]).toBe("var x = 'y'; function myFunc(arg1, arg2){}");
@@ -267,7 +267,7 @@ describe("functionRegex", () => {
267267
const nonCapturingRegEx = functionRegex(funcName, ["arg1", "arg2"]);
268268

269269
const nonCapturingMatch = "function myFunc(arg1, arg2){}".match(
270-
nonCapturingRegEx
270+
nonCapturingRegEx,
271271
);
272272
expect(nonCapturingMatch).not.toBeNull();
273273
expect(nonCapturingMatch![1]).toBeUndefined();
@@ -288,13 +288,13 @@ describe("functionRegex", () => {
288288

289289
const match =
290290
"myFunc = arg1 => arg1; console.log()\n // captured, unfortunately".match(
291-
regEx
291+
regEx,
292292
);
293293
expect(match).not.toBeNull();
294294
// It's a greedy match, since it doesn't know where the function ends.
295295
// This should be fine for most use cases.
296296
expect(match![1]).toBe(
297-
"myFunc = arg1 => arg1; console.log()\n // captured, unfortunately"
297+
"myFunc = arg1 => arg1; console.log()\n // captured, unfortunately",
298298
);
299299
});
300300

@@ -337,7 +337,7 @@ describe("functionRegex", () => {
337337
const combinedRegEx = helper.concatRegex(/var x = 'y'; /, regEx);
338338

339339
const match = "var x = 'y'; function myFunc(arg1, arg2){return true}".match(
340-
combinedRegEx
340+
combinedRegEx,
341341
);
342342
expect(match).not.toBeNull();
343343
expect(match![0]).toBe("var x = 'y'; function myFunc(arg1, arg2){");
@@ -354,7 +354,7 @@ describe("functionRegex", () => {
354354

355355
const match =
356356
"var x = 'y'; let myFunc = (arg1, arg2) => {return true}".match(
357-
combinedRegEx
357+
combinedRegEx,
358358
);
359359
expect(match).not.toBeNull();
360360
expect(match![0]).toBe("var x = 'y'; let myFunc = (arg1, arg2) => {");

lib/__tests__/python.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ for i in range(10):
175175
b = 3
176176
if b == 3:
177177
a = 4
178-
`
178+
`,
179179
);
180180
}
181181

@@ -213,7 +213,7 @@ def vigenere(message, key):
213213
const commentless_code = python.removeComments(el);
214214
const { block_body } = python.getBlock(commentless_code, "else")!;
215215
expect(block_body).toEqual(
216-
"\n key_char = key[key_index % len(key)]"
216+
"\n key_char = key[key_index % len(key)]",
217217
);
218218
});
219219
});

lib/index.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function escapeRegExp(exp: string): string {
101101

102102
export function isCalledWithNoArgs(
103103
calledFuncName: string,
104-
callingCode: string
104+
callingCode: string,
105105
): boolean {
106106
const noCommentsCallingCode = strip(callingCode);
107107
const funcExp = `^\\s*?${escapeRegExp(calledFuncName)}\\(\\s*?\\)`;
@@ -132,7 +132,7 @@ export function concatRegex(...regexes: (string | RegExp)[]) {
132132
export function functionRegex(
133133
funcName: string | null,
134134
paramList?: string[] | null,
135-
options?: { capture?: boolean; includeBody?: boolean }
135+
options?: { capture?: boolean; includeBody?: boolean },
136136
): RegExp {
137137
const capture = options?.capture ?? false;
138138
const includeBody = options?.includeBody ?? true;
@@ -167,24 +167,24 @@ interface ExtendedStyleDeclaration extends CSSStyleDeclaration {
167167

168168
const getIsDeclaredAfter = (styleRule: CSSStyleRule) => (selector: string) => {
169169
const cssStyleRules = Array.from(
170-
styleRule.parentStyleSheet?.cssRules || []
170+
styleRule.parentStyleSheet?.cssRules || [],
171171
)?.filter((ele) => ele.type === CSSRule.STYLE_RULE) as CSSStyleRule[];
172172
const previousStyleRule = cssStyleRules.find(
173-
(ele) => ele?.selectorText === selector
173+
(ele) => ele?.selectorText === selector,
174174
);
175175
if (!previousStyleRule) return false;
176176
const currPosition = Array.from(
177-
styleRule.parentStyleSheet?.cssRules || []
177+
styleRule.parentStyleSheet?.cssRules || [],
178178
).indexOf(styleRule);
179179
const prevPosition = Array.from(
180-
previousStyleRule?.parentStyleSheet?.cssRules || []
180+
previousStyleRule?.parentStyleSheet?.cssRules || [],
181181
).indexOf(previousStyleRule);
182182
return currPosition > prevPosition;
183183
};
184184

185185
export async function prepTestComponent(
186186
component: unknown,
187-
props?: Record<string, unknown>
187+
props?: Record<string, unknown>,
188188
) {
189189
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
190190
const testDiv = document.createElement("div");
@@ -204,7 +204,7 @@ export const python = {
204204
getDef(code: string, functionName: string) {
205205
const regex = new RegExp(
206206
`\\n?(?<function_indentation> *?)def +${functionName} *\\((?<function_parameters>[^\\)]*)\\)\\s*:\\s*?\\n?(?<function_body>.*?)(?=\\n\\k<function_indentation>[\\w#]|$)`,
207-
"s"
207+
"s",
208208
);
209209

210210
const matchedCode = regex.exec(code);
@@ -218,7 +218,7 @@ export const python = {
218218

219219
const functionIndentationSansNewLine = function_indentation.replace(
220220
/\n+/,
221-
""
221+
"",
222222
);
223223
return {
224224
// Entire function definition without leading \n
@@ -251,7 +251,7 @@ export const python = {
251251

252252
const regex = new RegExp(
253253
`\\n?(?<block_indentation> *?)(?<block_condition>${escapedBlockPattern})\\s*:\\s*?\\n(?<block_body>(\\k<block_indentation> +[^\\n]*| *\\n)+)(\n|$)`,
254-
"sm"
254+
"sm",
255255
);
256256

257257
const matchedCode = regex.exec(code);
@@ -286,7 +286,7 @@ export class CSSHelp {
286286
private _getStyleRules() {
287287
const styleSheet = this.getStyleSheet();
288288
return this.styleSheetToCssRulesArray(styleSheet).filter(
289-
(ele) => ele.type === CSSRule.STYLE_RULE
289+
(ele) => ele.type === CSSRule.STYLE_RULE,
290290
) as CSSStyleRule[];
291291
}
292292

@@ -298,7 +298,7 @@ export class CSSHelp {
298298

299299
getStyle(selector: string): ExtendedStyleDeclaration | null {
300300
const style = this._getStyleRules().find(
301-
(ele) => ele?.selectorText === selector
301+
(ele) => ele?.selectorText === selector,
302302
)?.style as ExtendedStyleDeclaration | undefined;
303303
if (!style) return null;
304304
style.getPropVal = (prop: string, strip = false) => {
@@ -325,7 +325,7 @@ export class CSSHelp {
325325

326326
getStyleRule(selector: string): ExtendedStyleRule | null {
327327
const styleRule = this._getStyleRules()?.find(
328-
(ele) => ele?.selectorText === selector
328+
(ele) => ele?.selectorText === selector,
329329
);
330330
if (styleRule) {
331331
return {
@@ -357,7 +357,7 @@ export class CSSHelp {
357357

358358
isPropertyUsed(property: string): boolean {
359359
return this._getStyleRules().some((ele) =>
360-
ele.style?.getPropertyValue(property)
360+
ele.style?.getPropertyValue(property),
361361
);
362362
}
363363

@@ -371,17 +371,17 @@ export class CSSHelp {
371371
getStyleSheet(): CSSStyleSheet | null {
372372
// TODO: Change selector to match exactly 'styles.css'
373373
const link: HTMLLinkElement | null = this.doc?.querySelector(
374-
"link[href*='styles']"
374+
"link[href*='styles']",
375375
);
376376

377377
// When using the styles.css tab, we add a 'fcc-injected-styles' class so we can target that. This allows users to add external scripts without them interfering
378378
const stylesDotCss: HTMLStyleElement | null = this.doc?.querySelector(
379-
"style.fcc-injected-styles"
379+
"style.fcc-injected-styles",
380380
);
381381

382382
// For steps that use <style> tags, where they don't add the above class - most* browser extensions inject styles with class/media attributes, so it filters those
383383
const styleTag: HTMLStyleElement | null = this.doc?.querySelector(
384-
"style:not([class]):not([media])"
384+
"style:not([class]):not([media])",
385385
);
386386

387387
if (link?.sheet?.cssRules?.length) {
@@ -400,7 +400,7 @@ export class CSSHelp {
400400
}
401401

402402
styleSheetToCssRulesArray(
403-
styleSheet: ReturnType<CSSHelp["getStyleSheet"]>
403+
styleSheet: ReturnType<CSSHelp["getStyleSheet"]>,
404404
): CSSRule[] {
405405
return Array.from(styleSheet?.cssRules || []);
406406
}

lib/parse.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const parse = (input: string, options: Partial<options> = {}) => {
3131
let prev: Block | CodeNode | undefined;
3232

3333
const source = [BLOCK_OPEN_REGEX, BLOCK_CLOSE_REGEX].filter<RegExp>(
34-
(x): x is RegExp => typeof x !== "undefined"
34+
(x): x is RegExp => typeof x !== "undefined",
3535
);
3636
let tripleQuotes = false;
3737

@@ -50,7 +50,7 @@ export const parse = (input: string, options: Partial<options> = {}) => {
5050

5151
const scan = (
5252
regex: RegExp,
53-
type = "text"
53+
type = "text",
5454
):
5555
| { type: string; match: RegExpExecArray; value: string; newline?: string }
5656
| undefined => {

0 commit comments

Comments
 (0)