diff --git a/.eslintrc b/.eslintrc.js similarity index 65% rename from .eslintrc rename to .eslintrc.js index d30c30a8de4..e68cea6ecec 100644 --- a/.eslintrc +++ b/.eslintrc.js @@ -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"], @@ -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", @@ -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", @@ -134,4 +136,4 @@ } } ] -} +}; diff --git a/buildprocess/.eslintrc b/buildprocess/.eslintrc deleted file mode 100644 index 1e9490cb479..00000000000 --- a/buildprocess/.eslintrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "env": { - "browser": false, - "node": true - }, - "rules": { - "no-sync": 0 - } -} diff --git a/buildprocess/.eslintrc.js b/buildprocess/.eslintrc.js new file mode 100644 index 00000000000..56abb98121d --- /dev/null +++ b/buildprocess/.eslintrc.js @@ -0,0 +1,11 @@ +"use strict"; + +module.exports = { + env: { + browser: false, + node: true + }, + rules: { + "no-sync": 0 + } +}; diff --git a/doc/contributing/development-environment.md b/doc/contributing/development-environment.md index 6dbbac4979c..decb14e8d57 100644 --- a/doc/contributing/development-environment.md +++ b/doc/contributing/development-environment.md @@ -142,7 +142,7 @@ Run any of these tasks with `yarn gulp ` 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. diff --git a/test/.eslintrc b/test/.eslintrc deleted file mode 100644 index 52939e2adf9..00000000000 --- a/test/.eslintrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "env": { - "jasmine": true - } -} diff --git a/test/.eslintrc.js b/test/.eslintrc.js new file mode 100644 index 00000000000..7e0139be293 --- /dev/null +++ b/test/.eslintrc.js @@ -0,0 +1,7 @@ +"use strict"; + +module.exports = { + env: { + jasmine: true + } +};