Skip to content

Commit

Permalink
[#213][Pre-Commit] Add the fixmyjs Hook, and Appease it.
Browse files Browse the repository at this point in the history
I don't know exactly what was wrong with the
`Object.entries(...).forEach(([key, value]), () => {});` syntax, but
`fixmyjs` kept complaining about an `Unexpected token =>` for this loop
in particular, so we changed the loop to make it happy.
  • Loading branch information
pishoyg committed Aug 24, 2024
1 parent 22d7c4e commit 05cf316
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
10 changes: 8 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# See https://pre-commit.com for more information

# TODO: Add hooks from https://pre-commit.com/hooks.html.
# TODO: Add https://github.com/pre-commit/mirrors-fixmyjs. We ran into some
# versioning issues when we tried to add it today.

# N.B. Given fail_fast, you should the more problematic hooks first.
# See https://github.com/pishoyg/coptic/issues/94.
Expand All @@ -27,6 +25,14 @@ repos:
args: [--fix]
files: \.(js|jsx|mjs|cjs|ts|tsx|mts|cts)$
types: [file]
# NOTE:The non-legacy version of `fixmyjs` is rumored to be problematic. See
# https://github.com/pre-commit/mirrors-fixmyjs?tab=readme-ov-file#using-fixmyjs-with-pre-commit.
# Consider running with `--legacy` (or `-l`) if you run into any issues.
- repo: https://github.com/pre-commit/mirrors-fixmyjs
rev: 'v2.0.0'
hooks:
- id: fixmyjs
args: ['-c', '.jshintrc']
# TODO: Make your `jshint` configuration stricter.
# See https://jshint.com/docs/options/ and your `.jshintrc`.
- repo: https://github.com/pre-commit/mirrors-jshint
Expand Down
4 changes: 2 additions & 2 deletions flashcards/constants/a_coptic_dictionary/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ function moveElement(el: HTMLElement, tag: string, attrs: Record<string, string>
el.getAttributeNames().forEach((attr) => {
copy.setAttribute(attr, el.getAttribute(attr)!);
});
Object.entries(attrs).forEach(([key, value]) => {
for (const [key, value] of Object.entries(attrs)) {
copy.setAttribute(key, value);
});
}
el.parentNode?.replaceChild(copy, el);
}

Expand Down
4 changes: 2 additions & 2 deletions flashcards/data/build/a_coptic_dictionary/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ function moveElement(el, tag, attrs) {
el.getAttributeNames().forEach((attr) => {
copy.setAttribute(attr, el.getAttribute(attr));
});
Object.entries(attrs).forEach(([key, value]) => {
for (const [key, value] of Object.entries(attrs)) {
copy.setAttribute(key, value);
});
}
(_a = el.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(copy, el);
}
Array.prototype.forEach.call(document.getElementsByClassName('crum-page'), (el) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ window.addEventListener('load', () => { 'use strict';
el.getAttributeNames().forEach((attr) => {
copy.setAttribute(attr, el.getAttribute(attr));
});
Object.entries(attrs).forEach(([key, value]) => {
for (const [key, value] of Object.entries(attrs)) {
copy.setAttribute(key, value);
});
}
(_a = el.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(copy, el);
}
Array.prototype.forEach.call(document.getElementsByClassName('crum-page'), (el) => {
Expand Down

0 comments on commit 05cf316

Please sign in to comment.