@mlaursen/eslint-config
Advanced tools
Comparing version 2.1.1 to 2.2.0
151
index.js
@@ -1,2 +0,2 @@ | ||
const confusingBrowserGlobals = require('confusing-browser-globals'); | ||
const confusingBrowserGlobals = require("confusing-browser-globals"); | ||
@@ -6,25 +6,25 @@ let react = false; | ||
try { | ||
require.resolve('react'); | ||
require.resolve("react"); | ||
react = true; | ||
isNewJsx = parseInt(require('react').version, 10) > 16; | ||
isNewJsx = parseInt(require("react").version, 10) > 16; | ||
} catch (e) {} | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: 'module', | ||
sourceType: "module", | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:react/recommended', | ||
'plugin:react-hooks/recommended', | ||
isNewJsx && 'plugin:react/jsx-runtime', | ||
'plugin:import/errors', | ||
'plugin:import/warnings', | ||
'plugin:import/typescript', | ||
'plugin:jsx-a11y/recommended', | ||
'prettier', | ||
"eslint:recommended", | ||
"plugin:react/recommended", | ||
"plugin:react-hooks/recommended", | ||
isNewJsx && "plugin:react/jsx-runtime", | ||
"plugin:import/errors", | ||
"plugin:import/warnings", | ||
"plugin:import/typescript", | ||
"plugin:jsx-a11y/recommended", | ||
"prettier", | ||
].filter(Boolean), | ||
plugins: ['@typescript-eslint', 'jest', 'jsx-a11y', 'react-hooks', 'tsdoc'], | ||
plugins: ["@typescript-eslint", "jest", "jsx-a11y", "react-hooks", "tsdoc"], | ||
env: { | ||
@@ -36,20 +36,20 @@ es6: true, | ||
settings: { | ||
'import/extensions': ['.js', '.jsx', '.ts', '.tsx', '.d.ts'], | ||
'import/parsers': { | ||
'@typescript-eslint/parser': ['.ts', '.tsx'], | ||
"import/extensions": [".js", ".jsx", ".ts", ".tsx", ".d.ts"], | ||
"import/parsers": { | ||
"@typescript-eslint/parser": [".ts", ".tsx"], | ||
}, | ||
'import/resolver': { | ||
"import/resolver": { | ||
node: { | ||
extensions: ['.js', '.jsx', '.ts', '.tsx'], | ||
extensions: [".js", ".jsx", ".ts", ".tsx"], | ||
}, | ||
}, | ||
react: { | ||
version: react ? 'detect' : '17.0.0', | ||
version: react ? "detect" : "17.0.0", | ||
}, | ||
}, | ||
rules: { | ||
'no-console': 'warn', | ||
'no-use-before-define': 'warn', | ||
"no-console": "warn", | ||
"no-use-before-define": "warn", | ||
'no-restricted-globals': ['error', 'isFinite', 'isNaN'].concat( | ||
"no-restricted-globals": ["error", "isFinite", "isNaN"].concat( | ||
confusingBrowserGlobals | ||
@@ -59,26 +59,29 @@ ), | ||
// too many false positives with aliases/root dirs | ||
'import/no-unresolved': 'off', | ||
"import/no-unresolved": "off", | ||
curly: 'error', | ||
curly: "error", | ||
"object-shorthand": ["error", "always"], | ||
"no-useless-rename": ["error"], | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['**/*.ts', '**/*.tsx'], | ||
extends: ['plugin:@typescript-eslint/recommended'], | ||
files: ["**/*.ts", "**/*.tsx"], | ||
extends: ["plugin:@typescript-eslint/recommended"], | ||
rules: { | ||
// I want correct tsdoc syntax | ||
'tsdoc/syntax': 'warn', | ||
"tsdoc/syntax": "warn", | ||
'react/prop-types': 'off', | ||
"react/prop-types": "off", | ||
// have to disable since it can report incorrect errors | ||
'no-empty-function': 'off', | ||
"no-empty-function": "off", | ||
// I prefer shorthand syntax | ||
'@typescript-eslint/array-type': ['error', { default: 'array' }], | ||
"@typescript-eslint/array-type": ["error", { default: "array" }], | ||
// I prefer using `interface` over `type = {}` | ||
'@typescript-eslint/consistent-type-definitions': [ | ||
'error', | ||
'interface', | ||
"@typescript-eslint/consistent-type-definitions": [ | ||
"error", | ||
"interface", | ||
], | ||
@@ -89,4 +92,4 @@ | ||
// it can be derived. | ||
'@typescript-eslint/explicit-function-return-type': [ | ||
'error', | ||
"@typescript-eslint/explicit-function-return-type": [ | ||
"error", | ||
{ | ||
@@ -100,3 +103,3 @@ allowExpressions: true, | ||
// not a big fan of requiring unknown objects to require the index signature | ||
'@typescript-eslint/ban-types': 'off', | ||
"@typescript-eslint/ban-types": "off", | ||
@@ -108,13 +111,13 @@ // This is a "better" version of the `noUnusedLocals` and | ||
// omitted | ||
'@typescript-eslint/no-unused-vars': [ | ||
'error', | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
argsIgnorePattern: '^_', | ||
varsIgnorePattern: '^_', | ||
argsIgnorePattern: "^_", | ||
varsIgnorePattern: "^_", | ||
}, | ||
], | ||
'no-use-before-define': 'off', | ||
'@typescript-eslint/no-use-before-define': [ | ||
'warn', | ||
"no-use-before-define": "off", | ||
"@typescript-eslint/no-use-before-define": [ | ||
"warn", | ||
{ ignoreTypeReferences: true }, | ||
@@ -126,6 +129,6 @@ ], | ||
files: [ | ||
'src/setupTests.js', | ||
'src/setupTests.ts', | ||
'**/__tests__/**', | ||
'**/*.test.*', | ||
"src/setupTests.js", | ||
"src/setupTests.ts", | ||
"**/__tests__/**", | ||
"**/*.test.*", | ||
], | ||
@@ -137,40 +140,40 @@ env: { | ||
rules: { | ||
'prefer-template': 'off', | ||
"prefer-template": "off", | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/no-object-literal-type-assertion': 'off', | ||
'@typescript-eslint/no-var-requires': 'off', | ||
'@typescript-eslint/no-empty-function': 'off', | ||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'@typescript-eslint/no-empty-function': 'off', | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/explicit-function-return-type": "off", | ||
"@typescript-eslint/no-object-literal-type-assertion": "off", | ||
"@typescript-eslint/no-var-requires": "off", | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"@typescript-eslint/no-empty-function": "off", | ||
'jsx-a11y/no-autofocus': 'off', | ||
'jsx-a11y/no-static-element-interactions': 'off', | ||
'jsx-a11y/anchor-is-valid': 'off', | ||
'jsx-a11y/control-has-associated-label': 'off', | ||
"jsx-a11y/no-autofocus": "off", | ||
"jsx-a11y/no-static-element-interactions": "off", | ||
"jsx-a11y/anchor-is-valid": "off", | ||
"jsx-a11y/control-has-associated-label": "off", | ||
'react/prop-types': 'off', | ||
'react/display-name': 'off', | ||
'react/prefer-stateless-function': 'off', | ||
"react/prop-types": "off", | ||
"react/display-name": "off", | ||
"react/prefer-stateless-function": "off", | ||
}, | ||
}, | ||
{ | ||
files: ['**/__tests__/**', '**/*.test.*'], | ||
extends: ['plugin:jest/recommended'], | ||
files: ["**/__tests__/**", "**/*.test.*"], | ||
extends: ["plugin:jest/recommended"], | ||
rules: { | ||
// it's valid to do @jest-environment or other things in tests | ||
'tsdoc/syntax': 0, | ||
"tsdoc/syntax": 0, | ||
}, | ||
}, | ||
{ | ||
files: ['**/*.js', '**/*.jsx'], | ||
files: ["**/*.js", "**/*.jsx"], | ||
rules: { | ||
'no-unused-vars': [ | ||
'error', | ||
"no-unused-vars": [ | ||
"error", | ||
{ | ||
vars: 'all', | ||
varsIgnorePattern: '^_', | ||
args: 'after-used', | ||
varsIgnorePattern: '^_', | ||
vars: "all", | ||
varsIgnorePattern: "^_", | ||
args: "after-used", | ||
varsIgnorePattern: "^_", | ||
ignoreRestSiblings: true, | ||
@@ -177,0 +180,0 @@ }, |
{ | ||
"name": "@mlaursen/eslint-config", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "An eslint config used by mlaursen for most projects.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
8530
160