@tim-code/eslint-config 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +72 -0
  2. package/package.json +20 -0
package/index.js ADDED
@@ -0,0 +1,72 @@
1
+ /* eslint-disable no-inline-comments */
2
+ /* eslint-disable line-comment-position */
3
+ /* global module */
4
+
5
+ module.exports = {
6
+ env: {
7
+ es6: true,
8
+ },
9
+ root: true,
10
+ // may not be strictly required depending on configuration but in general babel parser is just better
11
+ parser: "@babel/eslint-parser",
12
+ parserOptions: {
13
+ ecmaVersion: 2020,
14
+ sourceType: "module",
15
+ // babel parser normally requires a config file
16
+ requireConfigFile: false,
17
+ },
18
+ reportUnusedDisableDirectives: true,
19
+ extends: ["eslint:all", "prettier", "plugin:import/recommended"],
20
+ rules: {
21
+ // .js extension needed for relative imports
22
+ "import/extensions": ["error", "ignorePackages"],
23
+
24
+ // null should be avoided entirely if possible
25
+ "no-restricted-syntax": [
26
+ "error",
27
+ {
28
+ selector:
29
+ ":not(BinaryExpression:matches([operator='!=='], [operator='==='])) > Literal[value=null]",
30
+ message:
31
+ 'Usage of "null" is discouraged except when used because of legacy APIs; use "undefined" instead',
32
+ },
33
+ ],
34
+
35
+ // modified rules
36
+ // four parameter functions seem more reasonable than three
37
+ "max-params": ["error", 4],
38
+ // sometimes need to pass an empty function as a callback
39
+ "no-empty-function": ["error", { allow: ["arrowFunctions"] }],
40
+ // function keyword is more readable in general but "fat arrow" is more concise; disables function(){} syntax
41
+ "func-style": ["error", "declaration", { allowArrowFunctions: true }],
42
+ // matches default IDE shortcut for multiline comments
43
+ "multiline-comment-style": ["error", "separate-lines"],
44
+ // errors need to be logged somehow
45
+ "no-console": ["error", { allow: ["error"] }],
46
+ // if each statement is one line, 15 statements can still be reasonable
47
+ "max-statements": ["error", 15],
48
+
49
+ // tolerable? perhaps even good ideas?
50
+ // no-underscore-dangle: "off" // does not apply to single underscore
51
+
52
+ // rule is too idealistic
53
+ camelcase: "off", // useful to allow non-camelcase for compatibility like destructuring JSON
54
+ "sort-keys": "off", // too burdensome; doesn't affect order of destructured properties i.e. ({b, a}) => ({a, b}) would be fine
55
+ "no-param-reassign": "off", // a common pattern is to coerce parameters; noisy to rename parameters slightly differently
56
+ "no-magic-numbers": "off", // does not allow 1, 2, -1; also sometimes noisy to name every constant (for example in time calculations)
57
+ "id-length": "off", // single character variables can sometimes be useful: i, j, x, y, $, _
58
+ "no-plusplus": "off", // ++ is too common of a language feature (C++)
59
+
60
+ // rule conflicts with another tool
61
+ "one-var": "off", // with Prettier, comma appears on the same line as declaration, making code less readable
62
+ "sort-imports": "off", // rely on IDE to sort imports; IDE sorts capitalizations differently than eslint expects
63
+ "new-cap": "off", // React functions can begin with capital letter
64
+
65
+ // bad rules
66
+ "init-declarations": "off", // doesn't make sense for let and subsequent assignment in if/else; const implies this rule anyway
67
+ "no-ternary": "off", // ternary is a useful language feature
68
+ "no-undefined": "off", // actually undefined should be used over null
69
+ "capitalized-comments": "off", // comments are not always sentences
70
+ "prefer-named-capture-group": "off", // named capture groups are too new
71
+ },
72
+ }
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@tim-code/eslint-config",
3
+ "version": "0.2.0",
4
+ "description": "",
5
+ "main": "",
6
+ "author": "",
7
+ "license": "MIT",
8
+ "dependencies": {
9
+ "@babel/core": ">= 7",
10
+ "@babel/eslint-parser": ">= 7",
11
+ "eslint-config-prettier": ">= 8"
12
+ },
13
+ "peerDependencies": {
14
+ "eslint": ">= 7",
15
+ "eslint-plugin-import": ">= 2"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ }
20
+ }