Skip to content

Commit

Permalink
Merge be081f6 into 53dea6e
Browse files Browse the repository at this point in the history
  • Loading branch information
AVykhrystyuk committed May 10, 2021
2 parents 53dea6e + be081f6 commit e539c1b
Show file tree
Hide file tree
Showing 16 changed files with 3,667 additions and 3,500 deletions.
38 changes: 28 additions & 10 deletions .eslintrc.js
Expand Up @@ -11,21 +11,20 @@ module.exports = {
// Append 'ts' extensions to Airbnb 'import/resolver' setting
'import/resolver': {
node: {
extensions: ['.mjs', '.js', '.ts', '.json'],
extensions: ['.js', '.ts', '.json'],
},
},
// Append 'ts' extensions to Airbnb 'import/extensions' setting
'import/extensions': ['.js', '.ts', '.mjs'],
'import/extensions': ['.js', '.ts'],
},
extends: [
'airbnb-base', // 'eslint-config-airbnb-base' package.
// "eslint:recommended", // 'eslint' package
// 'eslint:recommended', // 'eslint' package
'plugin:@typescript-eslint/eslint-recommended', // '@typescript-eslint/eslint-plugin' package
'plugin:@typescript-eslint/recommended', // '@typescript-eslint/eslint-plugin' package
'plugin:eslint-comments/recommended', // 'eslint-plugin-eslint-comments' package
'prettier', // 'eslint-config-prettier' package. Disables rules that conflicts with 'prettier'
'prettier/@typescript-eslint', // 'eslint-config-prettier' package. Disables rules that conflicts with 'prettier'
//'plugin:prettier/recommended', // Enables 'eslint-plugin-prettier' and displays prettier errors as ESLint errors. Should be the last configuration in the extends array.
// 'plugin:prettier/recommended', // Enables 'eslint-plugin-prettier' and displays prettier errors as ESLint errors. Should be the last configuration in the extends array.
],
rules: {
// https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
Expand All @@ -41,26 +40,45 @@ module.exports = {
// Prevent lines but allow TS overloads
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],

// Ensure consistent use of file extension within the import path
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
'import/extensions': ['error', 'ignorePackages', {
js: 'never',
ts: 'never',
}],

// Forbid the use of extraneous packages
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
// paths are treated both as absolute paths, and relative to process.cwd()
'import/no-extraneous-dependencies': ['error', {
devDependencies: [
'**/*{.,_}{test,spec}.ts', // tests where the extension or filename suffix denotes that it is a test
'**/rollup.config.js', // rollup config
'**/*{.,_}{test,spec}.ts',
'**/rollup.config.js',
'babel-register.js'
],
optionalDependencies: false,
}],

// Use function hoisting to improve code readability
'@typescript-eslint/no-use-before-define': ['error', 'nofunc'],
// Use function and class hoisting to improve code readability
'no-use-before-define': ['error', 'nofunc'],

// Allow implicit function return type for lambdas
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
// '@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],

// Allow properties in ctors, as it reduces code duplicates
'@typescript-eslint/no-parameter-properties': ['error', { allows: ['private readonly'] }],

'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
},
overrides: [
{
// enable the rules specifically for TypeScript files
files: ["*.ts"],
rules: {
'no-use-before-define': 'off',
// Use function hoisting to improve code readability
'@typescript-eslint/no-use-before-define': ['error', 'nofunc'],
}
}
]
};
1 change: 1 addition & 0 deletions .husky/.gitignore
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
4 changes: 2 additions & 2 deletions .travis.yml
@@ -1,8 +1,8 @@
language: node_js

node_js:
- 8
- 10
- 12
- 14

cache:
npm: true
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Expand Up @@ -11,5 +11,5 @@
"typescript",
"typescriptreact"
],
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
}
3 changes: 2 additions & 1 deletion babel-register.js
@@ -1,4 +1,5 @@
// eslint-disable-next-line import/no-extraneous-dependencies
/* eslint-disable @typescript-eslint/no-var-requires */

require('@babel/register')({
extensions: ['.js', '.ts'],
});
10 changes: 5 additions & 5 deletions babel.config.js
Expand Up @@ -19,8 +19,7 @@ function buildConfig(options) {
buildPresetEnv(options),
].filter(Boolean),
plugins: [
['@babel/plugin-proposal-class-properties', { loose: true }],
options.includeCoverage ? ['babel-plugin-istanbul'] : null,
options.includeCoverage && ['babel-plugin-istanbul'],
].filter(Boolean),
};
}
Expand All @@ -32,9 +31,10 @@ function buildPresetEnv({ buildType, isProduction, isTest }) {
return ['@babel/preset-env', {
debug: !isProduction,
loose: true,
modules: isTest ? 'commonjs' : 'false',
modules: isTest ? 'commonjs' : false,
targets: {
node: '8',
// TODO: is possible to take node version from travis script?
node: '14',
},
}];

Expand All @@ -48,6 +48,6 @@ function buildPresetEnv({ buildType, isProduction, isTest }) {

default:
/* es2019 - modern browsers */
return null;
return undefined;
}
}

0 comments on commit e539c1b

Please sign in to comment.