diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..5bec868f --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,42 @@ +module.exports = { + env: { + browser: true, + commonjs: true, + es6: true, + node: true + }, + extends: [ + "standard" + ], + globals: { + Atomics: "readonly", + SharedArrayBuffer: "readonly" + }, + parserOptions: { + ecmaVersion: 2018 + }, + rules: { + /* See https://eslint.org/docs/rules/ */ + /* 0: off, 1: warn, 2: error */ + + /* Style rules reflecting Tag's preferences */ + "brace-style": [1, "allman", { allowSingleLine: true }], + quotes: [2, "double"], + camelcase: 0, + semi: 0, + "space-before-function-paren": 0, + "one-var": 0, + + /* ESLint checks we should consider fixing in the future */ + eqeqeq: 0, + "no-unused-vars": 0, + "no-redeclare": 0, + "no-undef": 0, + "no-array-constructor": 0, + "prefer-const": 0, + "no-var": 0, + "no-extend-native": 0, + "prefer-regex-literals": 0, + "no-prototype-builtins": 0 + } +}; diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 0442f2ef..00000000 --- a/.prettierignore +++ /dev/null @@ -1,10 +0,0 @@ -node_modules/ -macos/ -debian/ -build/ -package.nw/lib/ol.js -package.nw/lib/moment-with-locales.js -package.nw/lib/moment-timezone-with-data.js -package.nw/lib/datepicker.js -package.nw/lib/third-party.js - diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index 1cbe6869..00000000 --- a/.prettierrc.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "printWidth": 80, - "overrides": [ - { - "files": ["*.html"], - "options": { - "printWidth": 120 - } - } - ] -} diff --git a/README.md b/README.md index ec9543ee..ca493df4 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,11 @@ among other things. ### Code Formatting -We use `prettier` to enforce code formatting rules, and we follow -the [JavaScript Standard Style](https://standardjs.com/) +We use `eslint` to enforce code formatting rules. You can use all kinds of plugins and configurations in your text editor to verify these rules, and even reformat code automatically, but if you want to run on the command line, you can (after running `npm install`) run the -`npm run prettier-check` command to verify the formatting of all files, or `npm run prettier-write` to reformat -all files to match the standard. - -If you want to know more about why these tools are useful, -[watch this talk](https://www.youtube.com/watch?v=kuHfMw8j4xk) +`npm run lint-check` command to verify the formatting of all files, or `npm run lint-fix` to reformat all files to match the standard. # Developer Environment Setup diff --git a/package.json b/package.json index 1982d686..e2b14977 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,18 @@ "name": "gridtracker-development", "version": "1.0.0", "devDependencies": { + "eslint": "^7.15.0", + "eslint-config-standard": "^16.0.2", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^4.2.1", "nwjs-builder-phoenix": "^1.15.0", "prettier": "^2.2.1" }, "scripts": { - "test": "npm run prettier-check", - "prettier-check": "npx prettier --check package.nw", - "prettier-write": "npx prettier --write package.nw", + "test": "eslint package.nw", + "lint-check": "eslint --fix package.nw", + "lint-fix": "eslint --fix package.nw", "dist": "build --concurrent --tasks win-x86,win-x64,linux-x86,linux-x64,mac-x64 package.nw", "distsome": "build --debug --tasks linux-x64,mac-x64 package.nw", "start": "run package.nw"