Skip to content
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

Eslint v9 #8236

Merged
merged 17 commits into from
Jun 3, 2024
Merged
10 changes: 2 additions & 8 deletions UI/css/system/ledgersmb-common.css
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,7 @@ body.menu,
color: var(--listtop-clr);
font-size: var(--listtop-font-size);
font-weight: bold;
padding-bottom: 0.1em;
padding-left: 1ex;
padding-right: 1ex;
padding-top: 0.1em;
padding: 0.1em 1ex;
}

.listheading,
Expand All @@ -269,10 +266,7 @@ thead th {
color: var(--listheading-clr);
font-size: var(--listheading-font-size);
font-weight: bold;
padding-bottom: 0.1em;
padding-left: 1ex;
padding-right: 1ex;
padding-top: 0.1em;
padding: 0.1em 1ex;
}

thead a:link {
Expand Down
259 changes: 259 additions & 0 deletions UI/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
/** @format */

import globals from "globals";
import babelParser from "@babel/eslint-parser";
import compatPlugin from "eslint-plugin-compat";
import eslintConfigESLint from "eslint-config-eslint";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import eslintImportX from "eslint-plugin-import-x";
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
import js from "@eslint/js";
import jest from "eslint-plugin-jest";
import packageJson from "eslint-plugin-package-json/configs/recommended";
import pluginVue from "eslint-plugin-vue";

export default [
// Global config
{
ignores: ["{js,node_modules,__mocks__}/**/*"]
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
},

js.configs.recommended,
eslintPluginPrettierRecommended,
...pluginVue.configs["flat/recommended"],
compatPlugin.configs["flat/recommended"],

// Config files
{
...eslintConfigESLint,
files: ["**/*.config.m?js"]
},
// JavaScript files
{
files: ["**/*.js"],
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
ignores: ["**/*.spec.js", "**/*.config.m?js"],
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
languageOptions: {
globals: {
...globals.browser,
...globals.es6,
...globals.amd,
...globals.node
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
},
ecmaVersion: 6,
sourceType: "module",
parser: babelParser,
parserOptions: {
requireConfigFile: false,
babelOptions: {
babelrc: false,
configFile: false,
presets: ["@babel/preset-env"]
},
templateSettings: {
evaluate: ["[%", "%]"],
interpolate: ["[%", "%]"],
escape: ["[%", "%]"]
}
}
},
plugins: {
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
"import-x": eslintImportX
},
settings: {
"import-x/resolver": "webpack",
"import-x/parsers": {
"@babel/eslint-parser": [".js", ".jsx"],
"@typescript-eslint/parser": [".ts", ".tsx"]
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
}
},
rules: {
...js.configs.recommended.rules,
camelcase: "off",
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
"compat/compat": "warn",
"consistent-return": "error",
curly: ["error", "all"],
"dot-notation": "error",
eqeqeq: "error",
"func-names": 0,
"global-require": "error",
"guard-for-in": "error",
"import-x/export": "error",
"import-x/no-unresolved": "error",
"import-x/named": "error",
"import-x/namespace": "error",
"import-x/default": "error",
"import-x/no-absolute-path": "error",
"import-x/no-dynamic-require": "error",
"import-x/no-named-as-default": "warn",
"import-x/no-named-as-default-member": "warn",
"import-x/no-duplicates": "warn",
"new-cap": 0,
"no-alert": "error",
"no-console": "off",
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
"no-continue": 0,
"no-else-return": "error",
"no-eval": "error",
"no-lonely-if": "error",
"no-multi-assign": "error",
"no-multi-spaces": "off",
"no-new-object": "error",
"no-param-reassign": "error",
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
"no-plusplus": 0,
"no-restricted-globals": "error",
"no-shadow": "error",
"no-template-curly-in-string": "error",
"no-undef": "error",
"no-underscore-dangle": 0,
"no-unused-expressions": "error",
"no-unused-vars": "error",
"no-use-before-define": "error",
"no-useless-escape": "error",
"no-useless-return": "error",
"one-var": [
"error",
{
initialized: "never",
uninitialized: "consecutive"
}
],
radix: "error",
"spaced-comment": [
"error",
"always",
{
block: {
balanced: true
}
}
],
"vars-on-top": "off",
yoda: "error",
"no-restricted-syntax": ["error", "SequenceExpression"]
}
},
// Package.json
{
files: ["package.json"],
...packageJson,
rules: {
...packageJson.rules,
"package-json/order-properties": [
"error",
{
order: [
"name",
"version",
"lockfileVersion",
"private",
"publishConfig",
"description",
"keywords",
"author",
"license",
"maintainers",
"contributors",
"bundlesize",
"main",
"browser",
"_browserslist-comment",
"browserslist",
"bugs",
"repository",
"files",
"bin",
"directories",
"man",
"config",
"dependencies",
"devDependencies",
"peerDependencies",
"optionalDependencies",
"bundledDependencies",
"homepage",
"scripts",
"engines",
"os",
"cpu",
"babel",
"eslintConfig",
"prettier",
"stylelint",
"lint-staged"
]
}
],
"package-json/sort-collections": [
"error",
["scripts", "devDependencies", "dependencies", "config"]
],
"prettier/prettier": [
"error",
{
tabWidth: 2
}
]
}
},
// Test files
{
files: [
"**/__tests__/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[tj]s?(x)"
],
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
...jest.configs["flat/recommended"],
rules: {
...jest.configs["flat/recommended"].rules,
"jest/prefer-expect-assertions": "off",
"jest/no-commented-out-tests": "off",
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
"no-console": "off",
camelcase: "off"
}
},
// Vue files
{
files: ["**/*.vue"],
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
rules: {
"vue/attribute-hyphenation": "off",
"vue/block-order": [
"error",
{
order: [
"script:not([setup])",
"script[setup]",
"template",
"style:not([scoped])",
"style[scoped]"
]
}
],
"vue/first-attribute-linebreak": "off",
"vue/html-closing-bracket-newline": "off",
"vue/html-indent": ["error", 4],
"vue/max-attributes-per-line": [
"error",
{
singleline: 3,
multiline: 3
}
],
"vue/multi-word-component-names": "off",
"vue/multiline-html-element-content-newline": "off",
"vue/no-setup-props-reactivity-loss": "off",
"vue/require-prop-types": "off",
"vue/singleline-html-element-content-newline": [
"error",
{
ignoreWhenNoAttributes: true,
ignoreWhenEmpty: true,
ignores: ["pre", "textarea", "template"],
externalIgnores: []
}
],
"vue/v-on-event-hyphenation": "off"
}
}
];
6 changes: 4 additions & 2 deletions UI/js-src/lsmb/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ define([
clickedAction: null,
onSubmit: function (evt) {
event.stop(evt);
this.clickedAction = evt.submitter; /* ought to be the same as this.domNode.__action */
this.clickedAction =
evt.submitter; /* ought to be the same as this.domNode.__action */
this.submit();
},
submit: function () {
Expand All @@ -25,7 +26,8 @@ define([
const options = { handleAs: "text" };
const method =
typeof this.method === "undefined" ? "GET" : this.method;
let url = this.action; /* relative; this.domNode.action is absolute */
let url =
this.action; /* relative; this.domNode.action is absolute */

options.doing = widget["data-lsmb-doing"];
options.done = widget["data-lsmb-done"];
Expand Down
5 changes: 1 addition & 4 deletions UI/js-src/lsmb/JumpScreenButton.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/** @format */

define(["dojo/_base/declare", "dijit/form/Button"], function (
declare,
button
) {
define(["dojo/_base/declare", "dijit/form/Button"], function (declare, button) {
return declare("lsmb/payments/JumpScreenButton", [button], {
url: null,
onClick: function () {
Expand Down
5 changes: 2 additions & 3 deletions UI/js-src/lsmb/PrintButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ define([
}
} else {
window.__lsmbReportError(r);
};
}
});
}
else {
} else {
this.inherited(arguments);
}
}
Expand Down
3 changes: 2 additions & 1 deletion UI/js-src/lsmb/SetupLoginButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ define([
"&database=" +
company +
"&csrf_token=" +
token);
token
);
},
function (err) {
var status = err.response.status;
Expand Down
12 changes: 6 additions & 6 deletions UI/js-src/lsmb/ToggleIncludeButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ define(["dojo/_base/declare", "dijit/form/Button"], function (declare, button) {
return declare("lsmb/payments/ToggleIncludeButton", [button], {
query: null,
onClick: function () {
dojo.query(this.query, this.valueNode.form).forEach(function (
node
) {
var n = dijit.getEnclosingWidget(node);
n.set("checked", !n.get("checked"));
});
dojo.query(this.query, this.valueNode.form).forEach(
function (node) {
ylavoie marked this conversation as resolved.
Show resolved Hide resolved
var n = dijit.getEnclosingWidget(node);
n.set("checked", !n.get("checked"));
}
);
}
});
});
3 changes: 1 addition & 2 deletions UI/js-src/lsmb/parts/PartDescription.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/** @format */

/* eslint no-template-curly-in-string:0 */

define([
"dijit/form/TextBox",
"dijit/_HasDropDown",
Expand Down Expand Up @@ -30,6 +28,7 @@ define([
channel: null,
height: null,
store: partRestStore,
// eslint-disable-next-line no-template-curly-in-string
queryExpr: "*${0}*",
autoComplete: false,
highlightMatch: "all",
Expand Down
2 changes: 1 addition & 1 deletion UI/js-src/lsmb/payments/PostPrintButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define([
let base = window.location.pathname.replace(/[^/]*$/, "");
let r = await fetch(base + domattr.get(f, "action"), {
method: "POST",
body: domform.toQuery(f),
body: domform.toQuery(f)
});

if (r.ok) {
Expand Down
Loading