Skip to content

Commit

Permalink
updated eslint configs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmartins committed Jun 2, 2024
1 parent 5aeaaeb commit 700c092
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 116 deletions.
12 changes: 0 additions & 12 deletions js/.eslintignore

This file was deleted.

93 changes: 0 additions & 93 deletions js/.eslintrc.json

This file was deleted.

93 changes: 93 additions & 0 deletions js/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import babel from "@babel/eslint-plugin";
import globals from "globals";
import babelParser from "@babel/eslint-parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);


const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: [
"**/**.json",
"**/*.test.js",
"**/__test__/*.js",
"**/*.config.js",
"**/**.html",
"**/karma*.js",
"**/node_modules/**/*",
"**/dist/**/*",
"**/lib/**/*",
"**/jupyterlab_francy/**/*",
"**/webpack.js",
"**/static/**/*",
],
}, ...compat.extends("eslint:recommended"), {
plugins: {
"@babel": babel,
},

languageOptions: {
globals: {
...globals.browser,
...globals.commonjs,
...globals.node,
d3: true,
VERSION: true,
DESCRIPTION: true,
FRANCY_DESC: true,
MathJax: true,
},

parser: babelParser,
ecmaVersion: "latest",
sourceType: "module",

parserOptions: {
requireConfigFile: false,

babelOptions: {
babelrc: false,
configFile: false,

plugins: [["@babel/plugin-proposal-decorators", {
legacy: true,
}]],
},
},
},

rules: {
indent: ["error", 2],
"linebreak-style": ["error", "unix"],
quotes: ["error", "single"],
semi: ["error", "always"],
"no-else-return": 1,
"space-unary-ops": 2,
"brace-style": ["error", "1tbs"],

"no-unused-vars": [2, {
vars: "all",
varsIgnorePattern: ".*ignore",
}],

"no-global-assign": ["error", {
exceptions: ["__webpack_public_path__", "__dirname"],
}],

"sort-imports": ["error", {
ignoreCase: false,
ignoreDeclarationSort: false,
ignoreMemberSort: false,
memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
}],
},
}];
36 changes: 30 additions & 6 deletions js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
"clean": "lerna run clean --stream",
"version": "lerna version --no-git-tag-version --no-push --no-private",
"docs": "jsdoc --verbose --recurse --configure .jsdoc.json",
"lint": "eslint --config .eslintrc.json packages/francy*",
"lint:fix": "eslint --fix --config .eslintrc.json packages/francy*",
"lint": "eslint --config eslint.config.mjs packages/francy*",
"lint:fix": "eslint --fix --config eslint.config.mjs packages/francy*",
"coverage": "yarn run test"
},
"devDependencies": {
"globals": "^15.3.0",
"@babel/cli": "^7.24.6",
"@babel/core": "^7.24.6",
"@babel/eslint-parser": "^7.24.6",
Expand Down Expand Up @@ -55,6 +56,8 @@
"d3-transition": "^3.0.1",
"d3-zoom": "^3.0.0",
"eslint": "^9.4.0",
"@eslint/js": "^9.4.0",
"@eslint/eslintrc": "^3.1.0",
"file-loader": "^6.2.0",
"jsdoc": "^4.0.3",
"json-loader": "^0.5.7",
Expand Down
9 changes: 7 additions & 2 deletions js/packages/francy-core/src/render/graph/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,28 @@ export default class Graph extends Renderer {
}

setLabelXPosition(element, width) {
/* eslint-disable no-unused-vars */
try {
element.attr('x', -Math.ceil(width / 2));
} catch (Error) {
} catch (err) {

// don't care, this might fail for multiple reasons,
// the user might have switch renderer for instance,
// no worries if something is not properly aligned :P
}
/* eslint-enable no-unused-vars */
}

setLabelYPosition(element, height) {
/* eslint-disable no-unused-vars */
try {
element.attr('y', -Math.ceil(height / 2));
} catch (Error) {
} catch (err) {
// don't care, this might fail for multiple reasons,
// the user might have switch renderer for instance,
// no worries if something is not properly aligned :P
}
/* eslint-enable no-unused-vars */
}

handleTypesetting(text) {
Expand Down
4 changes: 4 additions & 0 deletions js/packages/francy-renderer-graphviz/src/graph/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,27 @@ export default class GraphGeneric extends Graph {
}

setLabelXPosition(element, x) {
/* eslint-disable no-unused-vars */
try {
element.attr('x', Math.ceil(x * 2));
} catch (Error) {
// don't care, this might fail for multiple reasons,
// the user might have switch renderer for instance,
// no worries if something is not properly aligned :P
}
/* eslint-enable no-unused-vars */
}

setLabelYPosition(element, y) {
/* eslint-disable no-unused-vars */
try {
element.attr('y', -Math.ceil(y * 2));
} catch (Error) {
// don't care, this might fail for multiple reasons,
// the user might have switch renderer for instance,
// no worries if something is not properly aligned :P
}
/* eslint-enable no-unused-vars */
}

_connectedNodes(node, canvasNodes, link, canvasLinks) {
Expand Down
7 changes: 6 additions & 1 deletion js/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@
minimatch "^3.1.2"
strip-json-comments "^3.1.1"

"@eslint/[email protected]":
"@eslint/[email protected]", "@eslint/js@^9.4.0":
version "9.4.0"
resolved "https://registry.npmjs.org/@eslint/js/-/js-9.4.0.tgz"
integrity sha512-fdI7VJjP3Rvc70lC4xkFXHB0fiPeojiL1PxVG6t1ZvXQrarj893PweuBTujxDUFk0Fxj4R7PIIAZ/aiiyZPZcg==
Expand Down Expand Up @@ -5653,6 +5653,11 @@ globals@^14.0.0:
resolved "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz"
integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==

globals@^15.3.0:
version "15.3.0"
resolved "https://registry.npmjs.org/globals/-/globals-15.3.0.tgz"
integrity sha512-cCdyVjIUVTtX8ZsPkq1oCsOsLmGIswqnjZYMJJTGaNApj1yHtLSymKhwH51ttirREn75z3p4k051clwg7rvNKA==

globalthis@^1.0.3:
version "1.0.3"
resolved "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz"
Expand Down

0 comments on commit 700c092

Please sign in to comment.