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

Update to ESLint 8.57.0 #7150

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
92 changes: 47 additions & 45 deletions .eslintrc → .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,67 @@
{
"root": true,
"extends": [
"use strict";

module.exports = {
root: true,
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"requireConfigFile": false,
"ecmaVersion": 2019,
"ecmaFeatures": {
"jsx": true,
"modules": true,
"legacyDecorators": true
parser: "@typescript-eslint/parser",
parserOptions: {
requireConfigFile: false,
ecmaVersion: 2019,
ecmaFeatures: {
jsx: true,
modules: true,
legacyDecorators: true
}
},
"env": {
"browser": true,
"commonjs": true,
"es6": true
env: {
browser: true,
commonjs: true,
es6: true
},
"ignorePatterns": ["*.scss.d.ts"],
"plugins": ["react", "react-hooks", "@typescript-eslint"],
"globals": {
"process": true
ignorePatterns: ["*.scss.d.ts"],
plugins: ["react", "react-hooks", "@typescript-eslint"],
globals: {
process: true
},
"settings": {
"react": {
"version": "detect"
settings: {
react: {
version: "detect"
}
},
"rules": {
rules: {
"react-hooks/exhaustive-deps": "error",
"react/jsx-boolean-value": ["error", "never", { "always": [] }],
"react/jsx-boolean-value": ["error", "never", { always: [] }],
"react/no-arrow-function-lifecycle": "error",
"react/no-invalid-html-attribute": "error",
"react/jsx-no-useless-fragment": "error",
"react/jsx-no-constructed-context-values": "error",
"react/jsx-fragments": ["error", "syntax"],
"react/jsx-no-duplicate-props": ["error", { "ignoreCase": true }],
"react/jsx-no-duplicate-props": ["error", { ignoreCase: true }],
"react/jsx-pascal-case": [
"error",
{
"allowAllCaps": true,
"ignore": []
allowAllCaps: true,
ignore: []
}
],
"react/no-danger": "warn",
"react/no-did-update-set-state": "error",
"react/no-will-update-set-state": "error",
"react/self-closing-comp": "error",
"react/jsx-no-undef": ["error", { "allowGlobals": true }],
"react/jsx-no-undef": ["error", { allowGlobals: true }],

/*Possible Errors */
"no-console": "off",
"no-inner-declarations": [1, "functions"],

/* Best Practices */
"eqeqeq": ["error"],
eqeqeq: ["error"],
"no-alert": ["error"],
"no-caller": ["error"],
"no-div-regex": ["error"],
Expand All @@ -79,25 +81,25 @@
"no-return-assign": ["error"],
"no-script-url": ["error"],
"no-sequences": ["error"],
"radix": "error",
radix: "error",

/* Strict Mode */
"strict": [0, "global"],
strict: [0, "global"],

/* Variables */
"no-label-var": 1,
"no-unused-vars": [
"warn",
{
"vars": "local",
"args": "none"
vars: "local",
args: "none"
}
],

"camelcase": [
camelcase: [
0,
{
"properties": "always"
properties: "always"
}
],
"no-array-constructor": "error",
Expand All @@ -107,23 +109,23 @@
/* See https://stackoverflow.com/questions/64646248/eslintrc-js-for-react-17-and-jsx-without-import-react/64646593#64646593 */
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"react/no-unknown-property": ["error", { "ignore": ["css"] }]
"react/no-unknown-property": ["error", { ignore: ["css"] }]
},
"overrides": [
overrides: [
{
"files": ["**/*.ts", "**/*.tsx"],
"rules": {
files: ["**/*.ts", "**/*.tsx"],
rules: {
// @TODO: revise these rules
"@typescript-eslint/consistent-type-assertions": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"ignoreRestSiblings": true
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
ignoreRestSiblings: true
}
],
"@typescript-eslint/ban-ts-comment": "warn",
Expand All @@ -134,4 +136,4 @@
}
}
]
}
};
9 changes: 0 additions & 9 deletions buildprocess/.eslintrc

This file was deleted.

11 changes: 11 additions & 0 deletions buildprocess/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use strict";

module.exports = {
env: {
browser: false,
node: true
},
rules: {
"no-sync": 0
}
};
2 changes: 1 addition & 1 deletion doc/contributing/development-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Run any of these tasks with `yarn gulp <task name>` from within the TerriaJS dir
- `build` - Builds a non-minified version of the TerriaJS tests. This task may take 10 seconds or more, which is the main reason for the next task.
- `watch` - Starts the same as `build` but then it stays running and watches for changes to any TerriaJS or Cesium source file that was pulled in to the build. When a change to any of these files is detected, a fast incremental build is automatically kicked off. The incremental build is much faster than the full rebuild because dependencies between source files are cached.
- `release` - The same as `build` except that it also minifies the build tests.
- `lint` - Runs ESLint on the files in the `lib` folder and reports any problems. The ESLint rules are defined in the `.eslintrc` file in the root directory of TerriaJS. A stricter set of rules is also find in the `.eslintrc` file in `lib/ReactViews`.
- `lint` - Runs ESLint on the files in the `lib` folder and reports any problems. The ESLint rules are defined in the `.eslintrc.js` file in the root directory of TerriaJS.
- `docs` - Generates the user guide and reference documentation. The user guide is served at `http://localhost:3002/doc/guide/` and the reference documentation is at `http://localhost:3002/doc/reference/`.
- `make-schema` - Generates [JSON Schema](http://json-schema.org/) for the TerriaJS [Initialization Files](../customizing/initialization-files.md) from the source code. The schema is written to `wwwroot/schema`.
- `test` - Detects browsers available on the local system and launches the test suite in each. The results are reported on the command line.
Expand Down
39 changes: 26 additions & 13 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,32 @@ gulp.task("watch-specs", function (done) {
});

gulp.task("lint", function (done) {
var runExternalModule = require("./buildprocess/runExternalModule");

runExternalModule("eslint/bin/eslint.js", [
"lib",
"test",
"--ext",
".jsx,.js,.ts,.tsx",
"--ignore-pattern",
"lib/ThirdParty",
"--max-warnings",
"0"
]);

const spawnSync = require("child_process").spawnSync;
// If upgrading to ESLint 9 without changing config file format:
// process.env.ESLINT_USE_FLAT_CONFIG = "false";
const result = spawnSync(
"node_modules/eslint/bin/eslint.js",
[
"lib",
"test",
"--ext",
".jsx,.js,.ts,.tsx",
"--ignore-pattern",
"lib/ThirdParty",
"--max-warnings",
"0"
],
{
stdio: "inherit",
shell: true
}
);
if (result.status !== 0) {
const PluginError = require("plugin-error");
throw new PluginError("eslint", "ESLint exited with an error.", {
showStack: false
});
}
done();
});

Expand Down
3 changes: 2 additions & 1 deletion lib/Models/Catalog/Ows/WebMapServiceCapabilitiesStratum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export default class WebMapServiceCapabilitiesStratum extends LoadableStratum(
Array.from(this.capabilitiesLayers.values()).forEach((layer) => {
if (!layer?.MetadataURL) return;
Array.isArray(layer?.MetadataURL)
? metadataUrls.push(...layer?.MetadataURL)
? // eslint-disable-next-line no-unsafe-optional-chaining
metadataUrls.push(...layer?.MetadataURL)
: metadataUrls.push(layer?.MetadataURL as MetadataURL);
});

Expand Down
1 change: 1 addition & 0 deletions lib/Models/Catalog/Ows/WebMapTileServiceCatalogItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ class WebMapTileServiceCatalogItem extends MappableMixin(
let tileMatrixSetLinks: TileMatrixSetLink[] = [];
if (layer?.TileMatrixSetLink) {
if (Array.isArray(layer?.TileMatrixSetLink)) {
// eslint-disable-next-line no-unsafe-optional-chaining
tileMatrixSetLinks = [...layer?.TileMatrixSetLink];
} else {
tileMatrixSetLinks = [layer.TileMatrixSetLink];
Expand Down
1 change: 1 addition & 0 deletions lib/Models/Workflows/TableStylingWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,7 @@ export default class TableStylingWorkflow
),
isOpen: true,
selectableDimensions: filterOutUndefined([
// eslint-disable-next-line no-unsafe-optional-chaining
...traits.enum?.map((enumPoint, idx) => {
const dims: SelectableDimensionGroup = {
type: "group",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
"@typescript-eslint/parser": "^6.12.0",
"babel-plugin-styled-components": "^1.10.7",
"bufferutil": "^4.0.8",
"eslint": "^7.20.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^4.6.0",
Expand Down
5 changes: 0 additions & 5 deletions test/.eslintrc

This file was deleted.

7 changes: 7 additions & 0 deletions test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

module.exports = {
env: {
jasmine: true
}
};
Loading