Skip to content

Upgrade dev #1237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

1 change: 0 additions & 1 deletion .eslintrc.js

This file was deleted.

1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,12 @@ PACKAGE_NAME = "patternslib"
all:: bundle css


.PHONY: install
stamp-yarn install:
yarn.lock install:
$(YARN) install
# Install pre commit hook
$(YARN) husky install
# We have checked in the .husky files, so no need to add the commitlint hook again.
# $(YARN) husky add .husky/commit-msg "npx yarn commitlint --edit $1"
touch stamp-yarn


.PHONY: watch
watch: stamp-yarn
watch: install
$(YARN) watch


Expand All @@ -47,7 +41,7 @@ build: bundle css


.PHONY: depends-parser
depends-parser: stamp-yarn
depends-parser: install
$(PEGJS) -O size -f es src/lib/depends_parse.pegjs


Expand Down
11 changes: 11 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const config_eslint = require("@patternslib/dev/eslint.config.js");

module.exports = [
...config_eslint,
{
ignores: [
// Ignore auto-generated depends_parse.js file.
"src/lib/depends_parse.js",
],
},
]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"tippy.js": "^6.3.7"
},
"devDependencies": {
"@patternslib/dev": "^3.6.0",
"@patternslib/dev": "^3.7.2",
"@patternslib/pat-content-mirror": "^4.0.1",
"@patternslib/pat-doclock": "^3.0.0",
"@patternslib/pat-shopping-cart": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class ArgumentParser {
if (parameter.match(this.json_param_pattern)) {
try {
return JSON.parse(parameter);
} catch (e) {
} catch {
this.log.warn(`Invalid JSON argument found: ${parameter}.`);
}
}
Expand All @@ -348,7 +348,7 @@ class ArgumentParser {
try {
result[name] = this.parameters[name].value($el, name);
this.parameters[name].type = typeof result[name];
} catch (e) {
} catch {
this.log.error(`Default function for ${name} failed.`);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/core/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var store = {
// reported in #326
try {
store.supported = typeof window.sessionStorage !== "undefined";
} catch (e) {
} catch {
// just ignore.
}

Expand Down
4 changes: 3 additions & 1 deletion src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,12 @@ const debounce = (func, ms, timer = { timer: null }, postpone = true) => {
};
};

// TODO: Remove in next major release.
const isIE = () => {
// See: https://stackoverflow.com/a/9851769/1337474
// Internet Explorer 6-11
return /*@cc_on!@*/ false || !!document.documentMode;
// eslint-disable-next-line no-constant-binary-expression
return /*@cc_on!@*/false || !!document.documentMode;
};

const jqToNode = (el) => {
Expand Down
30 changes: 21 additions & 9 deletions src/pat/auto-suggest/auto-suggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@ export default Base.extend({
selectionClasses = JSON.parse(this.options.selectionClasses)[
obj.text
];
} catch (SyntaxError) {
log.error(
"SyntaxError: non-JSON data given to pat-autosuggest (selection-classes)"
);
} catch (e) {
if (e instanceof SyntaxError) {
log.error(
"SyntaxError: non-JSON data given to pat-autosuggest (selection-classes)"
);
} else {
throw e;
}
}
if (selectionClasses) {
// According to Cornelis the classes need to be applied on
Expand Down Expand Up @@ -161,9 +165,13 @@ export default Base.extend({
if (this.options.wordsJson?.length) {
try {
words = JSON.parse(this.options.wordsJson);
} catch (SyntaxError) {
words = [];
log.error("SyntaxError: non-JSON data given to pat-autosuggest");
} catch (e) {
if (e instanceof SyntaxError) {
words = [];
log.error("SyntaxError: non-JSON data given to pat-autosuggest");
} else {
throw e;
}
}
if (!Array.isArray(words)) {
words = words.map((v, k) => {
Expand Down Expand Up @@ -243,8 +251,12 @@ export default Base.extend({
}
callback(_data);
};
} catch (SyntaxError) {
log.error("SyntaxError: non-JSON data given to pat-autosuggest");
} catch (e) {
if (e instanceof SyntaxError) {
log.error("SyntaxError: non-JSON data given to pat-autosuggest");
} else {
throw e;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/pat/auto-suggest/auto-suggest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var testutils = {
var cfg = c || {};
return $("<input/>", {
"id": cfg.id || "select2",
"data-pat-autosuggest": "" || cfg.data,
"data-pat-autosuggest": cfg.data,
"class": "pat-autosuggest",
"type": "text",
}).appendTo($("div#lab"));
Expand Down
2 changes: 1 addition & 1 deletion src/pat/inject/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ const inject = {
if (cfg.delay) {
try {
cfg.delay = utils.parseTime(cfg.delay);
} catch (e) {
} catch {
log.warn("Invalid delay value: ", cfg.delay);
cfg.delay = null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pat/masonry/masonry.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default Base.extend({
var containerStyle;
try {
containerStyle = JSON.parse(this.options.containerStyle);
} catch (e) {
} catch {
containerStyle = { position: "relative" };
log.warn(
"Invalid value passed in as containerStyle. Needs to " +
Expand Down
4 changes: 2 additions & 2 deletions src/pat/push/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default Base.extend({
try {
const response = await fetch(this.options.url);
data = await response.text();
} catch (e) {
} catch {
logger.error(
`Could not fetch from ${this.options.url} on push-id ${this.options.pushId}.`
);
Expand Down Expand Up @@ -110,7 +110,7 @@ export default Base.extend({
try {
const response = await fetch(this.options.url);
data = await response.json();
} catch (e) {
} catch {
logger.error(
`Could not fetch from ${this.options.url} on push-id ${this.options.pushId}.`
);
Expand Down
2 changes: 1 addition & 1 deletion src/pat/stacks/stacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Pattern extends BasePattern {
if (selected) {
try {
this.$active = $sheets.filter("#" + selected);
} catch (e) {
} catch {
selected = undefined;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pat/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class Pattern extends BasePattern {
});
const text = await response.text();
content = await handler(text, url, selector);
} catch (e) {
} catch {
log.error("Error on ajax request. ${e}");
}
} else if (selector) {
Expand Down
2 changes: 1 addition & 1 deletion src/pat/tooltip/tooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const testutils = {
"id": cfg.id || "tooltip",
"href": cfg.href || "#anchor",
"title": cfg.title || "tooltip title attribute",
"data-pat-tooltip": "" || cfg.data,
"data-pat-tooltip": cfg.data,
"class": "pat-tooltip",
})
.text(cfg.content)
Expand Down
Loading
Loading