@mlaursen/eslint-config 2.1.0 → 2.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 +83 -80
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,90 +1,93 @@
1
- const confusingBrowserGlobals = require('confusing-browser-globals');
1
+ const confusingBrowserGlobals = require("confusing-browser-globals");
2
2
 
3
3
  let react = false;
4
4
  let isNewJsx = false;
5
5
  try {
6
- require.resolve('react');
6
+ require.resolve("react");
7
7
  react = true;
8
- isNewJsx = parseInt(require('react').version, 10) > 16;
8
+ isNewJsx = parseInt(require("react").version, 10) > 16;
9
9
  } catch (e) {}
10
10
 
11
11
  module.exports = {
12
- parser: '@typescript-eslint/parser',
12
+ parser: "@typescript-eslint/parser",
13
13
  parserOptions: {
14
14
  ecmaVersion: 2018,
15
- sourceType: 'module',
15
+ sourceType: "module",
16
16
  },
17
17
  extends: [
18
- 'eslint:recommended',
19
- 'plugin:react/recommended',
20
- 'plugin:react-hooks/recommended',
21
- isNewJsx && 'plugin:react/jsx-runtime',
22
- 'plugin:import/errors',
23
- 'plugin:import/warnings',
24
- 'plugin:import/typescript',
25
- 'plugin:jsx-a11y/recommended',
26
- 'prettier',
18
+ "eslint:recommended",
19
+ "plugin:react/recommended",
20
+ "plugin:react-hooks/recommended",
21
+ isNewJsx && "plugin:react/jsx-runtime",
22
+ "plugin:import/errors",
23
+ "plugin:import/warnings",
24
+ "plugin:import/typescript",
25
+ "plugin:jsx-a11y/recommended",
26
+ "prettier",
27
27
  ].filter(Boolean),
28
- plugins: ['@typescript-eslint', 'jest', 'jsx-a11y', 'react-hooks', 'tsdoc'],
28
+ plugins: ["@typescript-eslint", "jest", "jsx-a11y", "react-hooks", "tsdoc"],
29
29
  env: {
30
30
  es6: true,
31
31
  node: true,
32
32
  browser: true,
33
33
  },
34
34
  settings: {
35
- 'import/extensions': ['.js', '.jsx', '.ts', '.tsx', '.d.ts'],
36
- 'import/parsers': {
37
- '@typescript-eslint/parser': ['.ts', '.tsx'],
35
+ "import/extensions": [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
36
+ "import/parsers": {
37
+ "@typescript-eslint/parser": [".ts", ".tsx"],
38
38
  },
39
- 'import/resolver': {
39
+ "import/resolver": {
40
40
  node: {
41
- extensions: ['.js', '.jsx', '.ts', '.tsx'],
41
+ extensions: [".js", ".jsx", ".ts", ".tsx"],
42
42
  },
43
43
  },
44
44
  react: {
45
- version: react ? 'detect' : '17.0.0',
45
+ version: react ? "detect" : "17.0.0",
46
46
  },
47
47
  },
48
48
  rules: {
49
- 'no-console': 'warn',
50
- 'no-use-before-define': 'warning',
49
+ "no-console": "warn",
50
+ "no-use-before-define": "warn",
51
51
 
52
- 'no-restricted-globals': ['error', 'isFinite', 'isNaN'].concat(
52
+ "no-restricted-globals": ["error", "isFinite", "isNaN"].concat(
53
53
  confusingBrowserGlobals
54
54
  ),
55
55
 
56
56
  // too many false positives with aliases/root dirs
57
- 'import/no-unresolved': 'off',
57
+ "import/no-unresolved": "off",
58
58
 
59
- curly: 'error',
59
+ curly: "error",
60
+
61
+ "object-shorthand": ["error", "always"],
62
+ "no-useless-rename": ["error"],
60
63
  },
61
64
  overrides: [
62
65
  {
63
- files: ['**/*.ts', '**/*.tsx'],
64
- extends: ['plugin:@typescript-eslint/recommended'],
66
+ files: ["**/*.ts", "**/*.tsx"],
67
+ extends: ["plugin:@typescript-eslint/recommended"],
65
68
  rules: {
66
69
  // I want correct tsdoc syntax
67
- 'tsdoc/syntax': 'warn',
70
+ "tsdoc/syntax": "warn",
68
71
 
69
- 'react/prop-types': 'off',
72
+ "react/prop-types": "off",
70
73
 
71
74
  // have to disable since it can report incorrect errors
72
- 'no-empty-function': 'off',
75
+ "no-empty-function": "off",
73
76
 
74
77
  // I prefer shorthand syntax
75
- '@typescript-eslint/array-type': ['error', { default: 'array' }],
78
+ "@typescript-eslint/array-type": ["error", { default: "array" }],
76
79
 
77
80
  // I prefer using `interface` over `type = {}`
78
- '@typescript-eslint/consistent-type-definitions': [
79
- 'error',
80
- 'interface',
81
+ "@typescript-eslint/consistent-type-definitions": [
82
+ "error",
83
+ "interface",
81
84
  ],
82
85
 
83
86
  // Allow expressions to work with react hooks. Annoying to have to
84
87
  // typedef each arrow function in a `useEffect` or `useCallback` when
85
88
  // it can be derived.
86
- '@typescript-eslint/explicit-function-return-type': [
87
- 'error',
89
+ "@typescript-eslint/explicit-function-return-type": [
90
+ "error",
88
91
  {
89
92
  allowExpressions: true,
90
93
  // allow FC definitions for React
@@ -93,78 +96,78 @@ module.exports = {
93
96
  ],
94
97
 
95
98
  // not a big fan of requiring unknown objects to require the index signature
96
- '@typescript-eslint/ban-types': 'off',
99
+ "@typescript-eslint/ban-types": "off",
97
100
 
98
101
  // This is a "better" version of the `noUnusedLocals` and
99
102
  // `noUnusedParameters` from the tsconfig.json since it can catch
100
103
  // unused vars in rest parameters that weren't meant to be omitted. I
101
104
  // must manually rename to be _name so I know it was intentionally
102
105
  // omitted
103
- '@typescript-eslint/no-unused-vars': [
104
- 'error',
106
+ "@typescript-eslint/no-unused-vars": [
107
+ "error",
105
108
  {
106
- argsIgnorePattern: '^_',
107
- varsIgnorePattern: '^_',
109
+ argsIgnorePattern: "^_",
110
+ varsIgnorePattern: "^_",
108
111
  },
109
112
  ],
110
- },
111
113
 
112
- 'no-use-before-define': 'off',
113
- '@typescript-eslint/no-use-before-define': [
114
- 'warn',
115
- { ignoreTypeReferences: true },
116
- ],
114
+ "no-use-before-define": "off",
115
+ "@typescript-eslint/no-use-before-define": [
116
+ "warn",
117
+ { ignoreTypeReferences: true },
118
+ ],
119
+ },
117
120
  },
118
121
  {
119
122
  files: [
120
- 'src/setupTests.js',
121
- 'src/setupTests.ts',
122
- '**/__tests__/**',
123
- '**/*.test.*',
123
+ "src/setupTests.js",
124
+ "src/setupTests.ts",
125
+ "**/__tests__/**",
126
+ "**/*.test.*",
124
127
  ],
125
128
  env: {
126
129
  jest: true,
127
130
  },
128
131
  // allow for less strict rules when writing tests
129
132
  rules: {
130
- 'prefer-template': 'off',
131
-
132
- '@typescript-eslint/no-explicit-any': 'off',
133
- '@typescript-eslint/explicit-function-return-type': 'off',
134
- '@typescript-eslint/no-object-literal-type-assertion': 'off',
135
- '@typescript-eslint/no-var-requires': 'off',
136
- '@typescript-eslint/no-empty-function': 'off',
137
- '@typescript-eslint/ban-ts-comment': 'off',
138
- '@typescript-eslint/no-empty-function': 'off',
139
-
140
- 'jsx-a11y/no-autofocus': 'off',
141
- 'jsx-a11y/no-static-element-interactions': 'off',
142
- 'jsx-a11y/anchor-is-valid': 'off',
143
- 'jsx-a11y/control-has-associated-label': 'off',
144
-
145
- 'react/prop-types': 'off',
146
- 'react/display-name': 'off',
147
- 'react/prefer-stateless-function': 'off',
133
+ "prefer-template": "off",
134
+
135
+ "@typescript-eslint/no-explicit-any": "off",
136
+ "@typescript-eslint/explicit-function-return-type": "off",
137
+ "@typescript-eslint/no-object-literal-type-assertion": "off",
138
+ "@typescript-eslint/no-var-requires": "off",
139
+ "@typescript-eslint/no-empty-function": "off",
140
+ "@typescript-eslint/ban-ts-comment": "off",
141
+ "@typescript-eslint/no-empty-function": "off",
142
+
143
+ "jsx-a11y/no-autofocus": "off",
144
+ "jsx-a11y/no-static-element-interactions": "off",
145
+ "jsx-a11y/anchor-is-valid": "off",
146
+ "jsx-a11y/control-has-associated-label": "off",
147
+
148
+ "react/prop-types": "off",
149
+ "react/display-name": "off",
150
+ "react/prefer-stateless-function": "off",
148
151
  },
149
152
  },
150
153
  {
151
- files: ['**/__tests__/**', '**/*.test.*'],
152
- extends: ['plugin:jest/recommended'],
154
+ files: ["**/__tests__/**", "**/*.test.*"],
155
+ extends: ["plugin:jest/recommended"],
153
156
  rules: {
154
157
  // it's valid to do @jest-environment or other things in tests
155
- 'tsdoc/syntax': 0,
158
+ "tsdoc/syntax": 0,
156
159
  },
157
160
  },
158
161
  {
159
- files: ['**/*.js', '**/*.jsx'],
162
+ files: ["**/*.js", "**/*.jsx"],
160
163
  rules: {
161
- 'no-unused-vars': [
162
- 'error',
164
+ "no-unused-vars": [
165
+ "error",
163
166
  {
164
- vars: 'all',
165
- varsIgnorePattern: '^_',
166
- args: 'after-used',
167
- varsIgnorePattern: '^_',
167
+ vars: "all",
168
+ varsIgnorePattern: "^_",
169
+ args: "after-used",
170
+ varsIgnorePattern: "^_",
168
171
  ignoreRestSiblings: true,
169
172
  },
170
173
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlaursen/eslint-config",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "An eslint config used by mlaursen for most projects.",
5
5
  "main": "index.js",
6
6
  "repository": "https://github.com/mlaursen/eslint-config.git",