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
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
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
255 changes: 255 additions & 0 deletions UI/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
/** @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__/**/*}"]
},

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.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"]
}
},
rules: {
...js.configs.recommended.rules,
camelcase: "error",
"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-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: ["src/**/*.vue"],
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"
}
}
];
11 changes: 2 additions & 9 deletions UI/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ module.exports = {
collectCoverage: false,

// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: [
"{src,js-src}/**/*.{js,vue}",
"!**/webpack*.js"
],
collectCoverageFrom: ["{src,js-src}/**/*.{js,vue}", "!**/webpack*.js"],

// The directory where Jest should output its coverage files
coverageDirectory: "coverage",
Expand Down Expand Up @@ -109,11 +106,7 @@ module.exports = {
moduleDirectories: ["node_modules"],

// An array of file extensions your modules use
moduleFileExtensions: [
"js",
"json",
"vue"
],
moduleFileExtensions: ["js", "json", "vue"],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
Expand Down
1 change: 0 additions & 1 deletion UI/js-src/lsmb/DateTextBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ define([
this._formattedValue = "";
}

/* eslint no-param-reassign:0 */
/* Provide default 'old code' doesn't include in its templates */
if (!params.constraints) {
params.constraints = {};
Expand Down
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
7 changes: 4 additions & 3 deletions UI/js-src/lsmb/PrintButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ define([
__action: this.get("value"),
type: f.type.value,
id: f.id.value,
// eslint-disable-next-line camelcase
workflow_id: f.workflow_id ? f.workflow_id.value : "",
formname: f.formname.value,
// eslint-disable-next-line camelcase
language_code: f.language_code.value,
media: "screen",
format: f.format.value
Expand Down Expand Up @@ -86,10 +88,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"));
}
);
}
});
});
Loading
Loading