Skip to content

Commit

Permalink
Merge pull request #527 from foretagsplatsen/dependabot/npm_and_yarn/…
Browse files Browse the repository at this point in the history
…foretagsplatsen/eslint-plugin-14.0.0

build(deps-dev): bump @foretagsplatsen/eslint-plugin from 12.0.0 to 14.0.0
  • Loading branch information
DamienCassou authored Jan 6, 2025
2 parents bba1910 + 59d0442 commit d9f9347
Show file tree
Hide file tree
Showing 20 changed files with 1,484 additions and 564 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ module.exports = [
},
],
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-nested-functions": ["error", { threshold: 6 }],
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
"test:serve": "vitest --ui"
},
"devDependencies": {
"@foretagsplatsen/eslint-plugin": "^12.0.0",
"@foretagsplatsen/eslint-plugin": "^14.0.0",
"@vitest/coverage-v8": "^2.0.5",
"@vitest/ui": "^2.0.5",
"eslint": "^9.13.0",
"eslint": "^9.17.0",
"eslint-import-resolver-exports": "^1.0.0-beta.5",
"globals": "^15.14.0",
"jsdom": "^24.0.0",
Expand Down
10 changes: 5 additions & 5 deletions src/Widget2.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default class Widget2 {
*/
replace(aJQuery) {
this._withAttachHooks(() => {
let canvas = htmlCanvas(aJQuery);
const canvas = htmlCanvas(aJQuery);
canvas.root.asJQuery().empty();
this._renderBasicOn(canvas);
});
Expand Down Expand Up @@ -276,7 +276,7 @@ export default class Widget2 {
this.asJQuery().empty();

// re-render content on root
let html = htmlCanvas(this.asJQuery());
const html = htmlCanvas(this.asJQuery());

this._withChildrenRegistration(() => {
this.renderContentOn(html);
Expand Down Expand Up @@ -319,7 +319,7 @@ export default class Widget2 {
* the evaluation.
*/
_withAttachHooks(fn) {
let inRenderingLoop = !!getCurrentWidget();
const inRenderingLoop = !!getCurrentWidget();

if (!inRenderingLoop) {
this.triggerWillAttach();
Expand All @@ -343,7 +343,7 @@ export default class Widget2 {
* Create and expose one event per string argument.
*/
_createEvents() {
let names = Array.prototype.slice.apply(arguments);
const names = Array.prototype.slice.apply(arguments);

names.forEach((name) => this._createEvent(name));
}
Expand Down Expand Up @@ -376,7 +376,7 @@ export default class Widget2 {
}

_withChildrenRegistration(fn) {
let parent = getCurrentWidget();
const parent = getCurrentWidget();

if (parent) {
parent.registerChild(this);
Expand Down
2 changes: 1 addition & 1 deletion src/currentWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function setCurrentWidget(widget) {
* Set `widget` as the current widget while evaluating `fn`.
*/
export function withCurrentWidget(fn, widget) {
let previousCurrent = getCurrentWidget();
const previousCurrent = getCurrentWidget();

try {
setCurrentWidget(widget);
Expand Down
28 changes: 14 additions & 14 deletions src/htmlCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import jQuery from "jquery";
/** @typedef {({}|string|renderer|widget|htmlTagBrush|*)} renderable */

// Supported HTML 'tags'
let tags = (
const tags = (
"a abbr acronym address area article aside audio b bdi bdo big " +
"blockquote body br button canvas caption cite code col colgroup command " +
"datalist dd del details dfn div dl dt em embed fieldset figcaption figure " +
Expand All @@ -21,15 +21,15 @@ let tags = (
"video wbr"
).split(" ");

let svgTags = "svg circle path polygon rect text".split(" ");
const svgTags = "svg circle path polygon rect text".split(" ");

// Supported HTML attributes
let attributes = "href for id media rel src style title type".split(" ");
const attributes = "href for id media rel src style title type".split(" ");

let omitSymbol = {};
const omitSymbol = {};

// Supported HTML events
let events = (
const events = (
"blur focus focusin focusout load resize scroll unload " +
"click dblclick mousedown mouseup mousemove mouseover " +
"mouseout mouseenter mouseleave change input select submit " +
Expand All @@ -53,13 +53,13 @@ function HtmlCanvasConstructor(rootElement) {
* @param {renderable[]} [children] Renderable objects to append as children of brush.
*/
HtmlCanvasConstructor.prototype.tag = function (tagName, children) {
let tagBrush = htmlTagBrush({ tag: tagName, children });
const tagBrush = htmlTagBrush({ tag: tagName, children });
this.root.appendBrush(tagBrush);
return tagBrush;
};

HtmlCanvasConstructor.prototype.svgTag = function (tagName, children) {
let tagBrush = htmlTagBrush({
const tagBrush = htmlTagBrush({
tag: tagName,
namespaceURI: "http://www.w3.org/2000/svg",
children,
Expand All @@ -78,7 +78,7 @@ HtmlCanvasConstructor.prototype.svgTag = function (tagName, children) {
*/
tags.forEach((tagName) => {
HtmlCanvasConstructor.prototype[tagName] = function () {
let args = Array.prototype.slice.call(arguments);
const args = Array.prototype.slice.call(arguments);
return this.tag(tagName, args);
};
});
Expand All @@ -88,7 +88,7 @@ tags.forEach((tagName) => {
*/
svgTags.forEach((tagName) => {
HtmlCanvasConstructor.prototype[tagName] = function () {
let args = Array.prototype.slice.call(arguments);
const args = Array.prototype.slice.call(arguments);
return this.svgTag(tagName, args);
};
});
Expand All @@ -109,7 +109,7 @@ HtmlCanvasConstructor.prototype.omit = function () {
* @param anObject
*/
HtmlCanvasConstructor.prototype.render = function () {
let args = Array.prototype.slice.call(arguments);
const args = Array.prototype.slice.call(arguments);
this.root.render(args);
};

Expand Down Expand Up @@ -195,7 +195,7 @@ function TagBrushConstructor(spec) {
}
}

let elementCache = {};
const elementCache = {};

/**
* Creates a new element from tagName
Expand Down Expand Up @@ -255,7 +255,7 @@ Number.prototype.appendToBrush = function (brush) {
};

Array.prototype.appendToBrush = function (brush) {
let length = this.length;
const length = this.length;
for (let i = length - 1; i >= 0; i--) {
brush.append(this[length - i - 1]);
}
Expand Down Expand Up @@ -342,7 +342,7 @@ TagBrushConstructor.prototype.getElement = function (object) {
* @returns {htmlTagBrush}
*/
TagBrushConstructor.prototype.render = function () {
let args = Array.prototype.slice.call(arguments);
const args = Array.prototype.slice.call(arguments);
for (const arg of args) {
this.append(arg);
}
Expand Down Expand Up @@ -478,7 +478,7 @@ TagBrushConstructor.prototype.css = function (key, value) {
* @returns {{}}
*/
TagBrushConstructor.prototype.attr = function (object) {
for (let key in object) {
for (const key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) {
this.addAttribute(key, object[key]);
}
Expand Down
10 changes: 5 additions & 5 deletions src/router/hashLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import url from "./url.js";
* In modern browsers we use the "hashchange" event to listen for location changes. If not supported
* we poll for changes using a timer.
*/
let noHashChangeSupport = !("onhashchange" in window);
const noHashChangeSupport = !("onhashchange" in window);

/**
* Num ms between each location change poll on browsers without "hashchange"
*/
let pollInterval = 25;
const pollInterval = 25;

/**
* Manages and listens for changes in the hash fragment of the URL.
Expand Down Expand Up @@ -56,7 +56,7 @@ const hashLocation = object.subclass((that, my) => {
* @param {url|string} aUrl
*/
that.setUrl = function (aUrl) {
let aHash = urlToHash(aUrl);
const aHash = urlToHash(aUrl);
setWindowHash(aHash);
setCurrentHash(aHash);
};
Expand Down Expand Up @@ -169,9 +169,9 @@ const hashLocation = object.subclass((that, my) => {
}

function check() {
let windowHash = getWindowHash();
const windowHash = getWindowHash();

let urlChanged = my.currentHash !== windowHash;
const urlChanged = my.currentHash !== windowHash;
if (urlChanged) {
setCurrentHash(windowHash);
}
Expand Down
6 changes: 3 additions & 3 deletions src/router/parameterSegment.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ function parameterValidator(constraint) {

// Match against RegExp
if (constraint instanceof RegExp) {
let exp = new RegExp(constraint);
const exp = new RegExp(constraint);
return function (urlSegment) {
return exp.test(urlSegment);
};
}

// Match valid options in an array
if (Object.prototype.toString.call(constraint) === "[object Array]") {
let options = constraint.map((option) => option.toLowerCase());
const options = constraint.map((option) => option.toLowerCase());
return function (urlSegment) {
let val = urlSegment.toLowerCase();
const val = urlSegment.toLowerCase();
return options.indexOf(val) !== -1;
};
}
Expand Down
28 changes: 14 additions & 14 deletions src/router/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ const route = object.subclass((that, my) => {
*/
// eslint-disable-next-line no-shadow -- we should fix that later
that.matchUrl = function (url) {
let match = findMatch(url);
const match = findMatch(url);
if (!match) {
return routeMatchResult.routeNoMatchResult;
}

let result = createMatchResult(match, url);
const result = createMatchResult(match, url);
my.events.trigger("matched", result);

return result;
Expand All @@ -124,7 +124,7 @@ const route = object.subclass((that, my) => {
params ||= {};

// Try to expand route into URL
let urlSegments = [];
const urlSegments = [];

segments.forEach((routeSegment) => {
let urlSegment;
Expand All @@ -149,7 +149,7 @@ const route = object.subclass((that, my) => {
urlSegments.push(urlSegment);
});

let query = {};
const query = {};

Object.keys(params).forEach((param) => {
if (that.hasParameter(param)) return;
Expand Down Expand Up @@ -207,7 +207,7 @@ const route = object.subclass((that, my) => {

// All routeSegments much match corresponding URL segment
return sequence.every((routeSegment, index) => {
let urlSegment = urlSegments[index];
const urlSegment = urlSegments[index];
return urlSegment !== undefined && routeSegment.match(urlSegment);
});
}
Expand All @@ -220,7 +220,7 @@ const route = object.subclass((that, my) => {
*/
// eslint-disable-next-line no-shadow -- we should fix that later
function findMatch(url) {
let urlSegments = url.getSegments();
const urlSegments = url.getSegments();

// Try match url segments
if (isMatch(urlSegments)) {
Expand All @@ -247,7 +247,7 @@ const route = object.subclass((that, my) => {
*/
function ensureOptionalSequences() {
// Find positions for optionals
let optionalPositions = [];
const optionalPositions = [];

segments.forEach((segment, index) => {
if (!segment.isOptional()) return;
Expand All @@ -267,12 +267,12 @@ const route = object.subclass((that, my) => {
}

// Generate possible sequences
let possibleOptionalSequences = orderedSubsets(optionalPositions);
const possibleOptionalSequences = orderedSubsets(optionalPositions);

possibleOptionalSequences.forEach((sequence) => {
// Clone segments array and remove optionals matching
// indexes in index sequence
let optionalSequence = segments.slice();
const optionalSequence = segments.slice();

sequence.forEach((optionalIndex, numRemoved) => {
// Remove optional but take in to account that we have already
Expand All @@ -294,16 +294,16 @@ const route = object.subclass((that, my) => {
*/
// eslint-disable-next-line no-shadow -- we should fix that later
function createMatchResult(match, url) {
let urlSegments = url.getSegments();
const urlSegments = url.getSegments();

let parameterValues = {};
const parameterValues = {};

segments.forEach((routeSegment) => {
if (!routeSegment.isParameter()) {
return;
}

let matchedIndex = match.indexOf(routeSegment);
const matchedIndex = match.indexOf(routeSegment);
if (matchedIndex >= 0) {
parameterValues[routeSegment.getName()] = routeSegment.getValue(
urlSegments[matchedIndex],
Expand Down Expand Up @@ -333,10 +333,10 @@ const route = object.subclass((that, my) => {
* @returns {[[]]} Array with all subset arrays
*/
function orderedSubsets(input) {
let results = [];
const results = [];
let result;
let mask;
let total = Math.pow(2, input.length);
const total = Math.pow(2, input.length);

for (mask = 1; mask < total; mask++) {
result = [];
Expand Down
10 changes: 5 additions & 5 deletions src/router/routeFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import abstractSegment from "./abstractSegment.js";
* Token/Char used to separate segments in route patterns.
* @type {string}
*/
let routePatternSeparator = "/";
const routePatternSeparator = "/";

/**
* Creates a route from pattern. A pattern is a string with route segments
Expand All @@ -26,9 +26,9 @@ function routeFactory(pattern, options) {
}

options ||= {};
let segmentStrings = pattern.split(routePatternSeparator);
const segmentStrings = pattern.split(routePatternSeparator);

let nonEmptySegmentStrings = segmentStrings
const nonEmptySegmentStrings = segmentStrings
.map(Function.prototype.call, String.prototype.trim)
.filter(Boolean);

Expand All @@ -47,10 +47,10 @@ function routeFactory(pattern, options) {
function segmentFactory(segmentString, options) {
options ||= {};

let segments = abstractSegment.allSubclasses();
const segments = abstractSegment.allSubclasses();

// Find segment type from string
for (let segment of segments) {
for (const segment of segments) {
if (segment.match(segmentString)) {
return segment({
segmentString,
Expand Down
Loading

0 comments on commit d9f9347

Please sign in to comment.