Skip to content

Commit

Permalink
Merge pull request #84 from molindo/feat/typescript-improvements
Browse files Browse the repository at this point in the history
TypeScript improvements
  • Loading branch information
amannn authored Apr 1, 2022
2 parents e161134 + f0b1896 commit 539c8f1
Show file tree
Hide file tree
Showing 9 changed files with 2,004 additions and 2,973 deletions.
14 changes: 9 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = Object.assign({}, require('./javascript.js'), {
env: {
node: true,
jest: true
module.exports = Object.assign(
{},
{
extends: ['./javascript', './typescript', './cypress', './jest', './react'],
env: {
node: true,
jest: true
}
}
});
);
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# CHANGELOG

## 6.0.0

### Features

- Upgrade to TypeScript 4

### Fixes

- Disable TypeScript rules which cause false positives.
- Disallow `describe.only`.

### Breaking changes

- Requires ESLint 8

## 5.1.1

### Fixes
Expand Down
6 changes: 3 additions & 3 deletions cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ module.exports = {
rules: {
'no-restricted-properties': [
ERROR,
{
object: 'it',
...['it', 'describe', 'test'].map((name) => ({
object: name,
property: 'only',
message:
'This should only be used for debugging and removed afterwards.'
}
}))
]
}
};
19 changes: 16 additions & 3 deletions javascript.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const confusingBrowserGlobals = require('confusing-browser-globals');
const {testFiles, ERROR, OFF} = require('./config');
const {ERROR, OFF, testFiles} = require('./config');

module.exports = {
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 'latest'
},

plugins: ['import', 'prettier', 'unicorn'],

Expand Down Expand Up @@ -73,7 +75,18 @@ module.exports = {
ERROR,
{singleQuote: true, bracketSpacing: false, trailingComma: 'none'}
],
'spaced-comment': ERROR,
'spaced-comment': [
ERROR,
'always',
// Allow TypeScript reference imports with tripple slashes
// https://github.com/molindo/eslint-config-molindo/issues/69
{
line: {
markers: ['/'],
exceptions: ['/']
}
}
],
'unicorn/explicit-length-check': ERROR,
'unicorn/import-index': ERROR,
'unicorn/no-abusive-eslint-disable': ERROR,
Expand Down
5 changes: 3 additions & 2 deletions jest.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
const {ERROR} = require('./config');
const {ERROR, OFF} = require('./config');

module.exports = {
plugins: ['jest'],

extends: ['plugin:jest/recommended'],

rules: {
'jest/expect-expect': OFF,
'jest/consistent-test-it': [
ERROR,
{
fn: 'it',
withinDescribe: 'it'
}
],
'lowercase-name': [ERROR, {ignore: ['describe']}]
'jest/prefer-lowercase-title': [ERROR, {ignore: ['describe']}]
}
};
37 changes: 18 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-molindo",
"version": "5.1.1",
"version": "6.0.0",
"description": "Molindo ESLint config that implements our styleguide and helps to catch errors.",
"repository": "https://github.com/molindo/eslint-config-molindo",
"author": "Jan Amann <[email protected]>",
Expand All @@ -25,29 +25,28 @@
"tsconfig.json"
],
"devDependencies": {
"eslint": "7.4.0",
"jest": "26.1.0"
"eslint": "8.12.0",
"jest": "27.5.1"
},
"peerDependencies": {
"eslint": "^7.0.0"
"eslint": "^8.0.0"
},
"dependencies": {
"@rushstack/eslint-patch": "^1.0.2",
"@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.0.0",
"babel-eslint": "^10.0.0",
"confusing-browser-globals": "^1.0.0",
"@rushstack/eslint-patch": "^1.1.1",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"confusing-browser-globals": "^1.0.11",
"eslint-plugin-css-modules": "^2.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^24.4.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.6",
"eslint-plugin-sort-destructure-keys": "^1.3.5",
"eslint-plugin-unicorn": "^20.1.0",
"prettier": "^2.0.0",
"typescript": "^3.0.0"
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.1.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-sort-destructure-keys": "^1.4.0",
"eslint-plugin-unicorn": "^41.0.1",
"prettier": "^2.6.1",
"typescript": "^4.0.0"
},
"engines": {
"node": ">=10"
Expand Down
2 changes: 1 addition & 1 deletion react.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {testFiles, ERROR, OFF} = require('./config');
const {ERROR, OFF, testFiles} = require('./config');

module.exports = {
plugins: [
Expand Down
15 changes: 14 additions & 1 deletion typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ module.exports = Object.assign({}, javascript, {
{
files: ['**/*.ts', '**/*.tsx'],
extends: (javascript.extends || []).concat(
// This is a compatibility ruleset that:
// 1. Disables rules from eslint:recommended which are already handled by TypeScript.
// 2. Enables rules that make sense due to TS's typechecking / transpilation.
'plugin:@typescript-eslint/eslint-recommended',

'plugin:@typescript-eslint/recommended',
'plugin:import/typescript'
),
parserOptions: {
project: './tsconfig.json'
},
rules: {
// Use the one from TypeScript instead
// Creates false positives (see https://github.com/molindo/eslint-config-molindo/issues/70)
'import/export': OFF,
// Use the TypeScript alternatives
'no-unused-vars': OFF,
'no-shadow': OFF,
// The TypeScript compiler takes care of this
'import/no-unresolved': OFF,
'@typescript-eslint/array-type': [ERROR, {default: 'generic'}],
Expand All @@ -33,7 +41,12 @@ module.exports = Object.assign({}, javascript, {
'@typescript-eslint/no-for-in-array': ERROR,
'@typescript-eslint/no-inferrable-types': ERROR,
'@typescript-eslint/no-misused-promises': ERROR,
// There are valid use cases for this
// https://github.com/molindo/eslint-config-molindo/issues/83
'@typescript-eslint/no-empty-interface': OFF,
'@typescript-eslint/no-empty-function': OFF,
'@typescript-eslint/no-non-null-assertion': OFF,
'@typescript-eslint/no-shadow': [ERROR],
'@typescript-eslint/no-unused-vars': ERROR,
'@typescript-eslint/no-var-requires': OFF,
'@typescript-eslint/switch-exhaustiveness-check': ERROR,
Expand Down
Loading

0 comments on commit 539c8f1

Please sign in to comment.