Skip to content

Commit

Permalink
✨ feat: upgrade dependencies and rules
Browse files Browse the repository at this point in the history
  • Loading branch information
MrJmpl3 committed Apr 12, 2022
1 parent 1bc830c commit 95e4c8c
Show file tree
Hide file tree
Showing 13 changed files with 1,491 additions and 1,436 deletions.
768 changes: 0 additions & 768 deletions .yarn/releases/yarn-3.1.1.cjs

This file was deleted.

785 changes: 785 additions & 0 deletions .yarn/releases/yarn-3.2.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'

yarnPath: .yarn/releases/yarn-3.1.1.cjs
yarnPath: .yarn/releases/yarn-3.2.0.cjs
18 changes: 1 addition & 17 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
/*
* Copyright (c) 2021.
*
* File created to GLEN SOFT company.
*/

module.exports = {
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
require.resolve('./shared'),
],
rules: {
// encourages use of dot notation whenever possible
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/dot-notation.md
'dot-notation': 'off',
'@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],

// disallow use of eval()-like methods
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-implied-eval.md
'no-implied-eval': 'off',
'@typescript-eslint/no-implied-eval': ['error'],

// restrict what can be thrown as an exception
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-throw-literal.md
'no-throw-literal': 'off',
'@typescript-eslint/no-throw-literal': ['error'],
'@typescript-eslint/return-await': ['error', 'in-try-catch'],
},
};
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "eslint-config-airbnb-typescript-base",
"version": "3.1.0",
"description": "Airbnb Base Typescript config",
"license": "MIT",
"author": "José Manuel Casani Guerra <[email protected]>",
"main": "index.js",
"version": "3.0.1",
"scripts": {
"format": "yarn run format:package && yarn run format:prettier && yarn run format:eslint",
"format:eslint": "eslint --fix ./ >/dev/null 2>&1 || true",
Expand All @@ -16,28 +16,28 @@
"validate": "yarn run lint"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.18.0",
"confusing-browser-globals": "^1.0.11",
"eslint": "^8.5.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint": "^8.13.0",
"eslint-import-resolver-typescript": "^2.7.1",
"eslint-import-resolver-webpack": "^0.13.2",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-typescript-sort-keys": "^2.1.0"
},
"devDependencies": {
"commitlint": "^15.0.0",
"commitlint": "^16.2.3",
"commitlint-config-gitmoji": "^2.2.5",
"eslint-config-prettier": "^8.3.0",
"eslint-config-prettier": "^8.5.0",
"husky": "^7.0.4",
"lint-staged": "^12.1.2",
"pinst": "^2.1.6",
"prettier": "^2.5.1",
"prettier-package-json": "^2.6.0",
"typescript": "^4.5.4"
"lint-staged": "^12.3.7",
"pinst": "^3.0.0",
"prettier": "^2.6.2",
"prettier-package-json": "^2.6.3",
"typescript": "^4.6.3"
},
"lint-staged": {
"*.{js,ts}": "eslint"
},
"packageManager": "yarn@3.1.1"
"packageManager": "yarn@3.2.0"
}
9 changes: 7 additions & 2 deletions rules/bestPractices.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ module.exports = {

// disallow use of new operator for Function object
// https://eslint.org/docs/rules/no-new-func
'no-new-func': 'error',
'no-new-func': 'off',

// disallows creating new instances of String, Number, and Boolean
// https://eslint.org/docs/rules/no-new-wrappers
Expand Down Expand Up @@ -331,7 +331,7 @@ module.exports = {
// disallow redundant `return await`
// https://eslint.org/docs/rules/no-return-await
'no-return-await': 'off',
'@typescript-eslint/return-await': 'error',
'@typescript-eslint/return-await': 'off',

// disallow use of `javascript:` urls.
// https://eslint.org/docs/rules/no-script-url
Expand Down Expand Up @@ -421,6 +421,11 @@ module.exports = {
// https://eslint.org/docs/rules/prefer-named-capture-group
'prefer-named-capture-group': 'off',

// Prefer Object.hasOwn() over Object.prototype.hasOwnProperty.call()
// https://eslint.org/docs/rules/prefer-object-has-own
// TODO: semver-major: enable thus rule, once eslint v8.5.0 is required
'prefer-object-has-own': 'off',

// https://eslint.org/docs/rules/prefer-regex-literals
'prefer-regex-literals': [
'error',
Expand Down
12 changes: 0 additions & 12 deletions rules/es6.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
module.exports = {
env: {
es6: true,
},
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: {
generators: false,
objectLiteralDuplicateProperties: false,
},
},

rules: {
// enforces no braces where they can be omitted
// https://eslint.org/docs/rules/arrow-body-style
Expand Down
35 changes: 0 additions & 35 deletions rules/import.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,4 @@
module.exports = {
env: {
es6: true,
},
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
},
extends: [
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
},
'import/resolver': {
node: {
extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts'],
},
typescript: {
alwaysTryTypes: true,
},
// webpack: {
// config: require.resolve('../../../webpack.config.js'),
// },
},
'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.d.ts'],
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
'import/core-modules': [],
'import/ignore': [
'node_modules',
'\\.(coffee|scss|css|less|hbs|svg|json)$',
],
},
rules: {
// Static analysis:

Expand Down
3 changes: 0 additions & 3 deletions rules/node.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module.exports = {
env: {
node: true,
},
rules: {
// enforce return after a callback
'callback-return': 'off',
Expand Down
6 changes: 0 additions & 6 deletions rules/strict.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* Copyright (c) 2021.
*
* File created to GLEN SOFT company.
*/

module.exports = {
rules: {
// babel inserts `'use strict';` for us
Expand Down
8 changes: 6 additions & 2 deletions rules/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
],

// require camel case names
camelcase: ['error', { properties: 'never', ignoreDestructuring: false }],
camelcase: 'off',

// enforce or disallow capitalization of the first letter of a comment
// https://eslint.org/docs/rules/capitalized-comments
Expand Down Expand Up @@ -57,6 +57,9 @@ module.exports = {
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
enums: 'always-multiline',
generics: 'always-multiline',
tuples: 'always-multiline',
},
],

Expand Down Expand Up @@ -594,7 +597,8 @@ module.exports = {
'sort-vars': 'off',

// require or disallow space before blocks
'space-before-blocks': 'error',
'space-before-blocks': 'off',
'@typescript-eslint/space-before-blocks': 'error',

// require or disallow space before function opening parenthesis
// https://eslint.org/docs/rules/space-before-function-paren
Expand Down
83 changes: 82 additions & 1 deletion shared.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,44 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
generators: false,
objectLiteralDuplicateProperties: false,
},
},
plugins: ['import', '@typescript-eslint', 'typescript-sort-keys'],
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
},
'import/resolver': {
node: {
extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts'],
},
typescript: {
alwaysTryTypes: true,
},
},
'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.d.ts'],
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
'import/core-modules': [],
'import/ignore': [
'node_modules',
'\\.(coffee|scss|css|less|hbs|svg|json)$',
],
},
extends: [
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:typescript-sort-keys/recommended',
require.resolve('./rules/bestPractices'),
require.resolve('./rules/errors'),
Expand All @@ -21,5 +49,58 @@ module.exports = {
require.resolve('./rules/import'),
require.resolve('./rules/strict'),
],
plugins: ['@typescript-eslint', 'typescript-sort-keys'],
rules: {
// The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings. However, the existing `no-underscore-dangle` rule already takes care of this.
'@typescript-eslint/naming-convention': [
'error',
// Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables (23.10)
{
selector: 'variable',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
// Allow camelCase functions (23.2), and PascalCase functions (23.8)
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
// Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make TypeScript recommendations, we are assuming this rule would similarly apply to anything "type like", including interfaces, type aliases, and enums
{
selector: 'typeLike',
format: ['PascalCase'],
},
],
},
overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
// The following rules are enabled in Airbnb config, but are already checked (more thoroughly) by the TypeScript compiler
// Some of the rules also fail in TypeScript files, for example: https://github.com/typescript-eslint/typescript-eslint/issues/662#issuecomment-507081586
// Rules are inspired by: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts
'constructor-super': 'off',
'getter-return': 'off',
'no-const-assign': 'off',
'no-dupe-args': 'off',
'no-dupe-class-members': 'off',
'no-dupe-keys': 'off',
'no-func-assign': 'off',
'no-import-assign': 'off',
'no-new-symbol': 'off',
'no-obj-calls': 'off',
'no-redeclare': 'off',
'no-setter-return': 'off',
'no-this-before-super': 'off',
'no-undef': 'off',
'no-unreachable': 'off',
'no-unsafe-negation': 'off',
'valid-typeof': 'off',
// The following rules are enabled in Airbnb config, but are recommended to be disabled within TypeScript projects
// See: https://github.com/typescript-eslint/typescript-eslint/blob/13583e65f5973da2a7ae8384493c5e00014db51b/docs/linting/TROUBLESHOOTING.md#eslint-plugin-import
'import/named': 'off',
'import/no-named-as-default-member': 'off',
// Disable `import/no-unresolved`, see README.md for details
'import/no-unresolved': 'off',
},
},
],
};
Loading

0 comments on commit 95e4c8c

Please sign in to comment.