Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v22
v24
57 changes: 21 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,56 +13,41 @@ npm i -D @terrestris/eslint-config-typescript
Can be omitted for already existing dependencies, also usually the latest version will be installed when omitting the version when running `bun/npm i -D <package>`.

```bash
npm i -D eslint@^9
npm i -D @typescript-eslint/eslint-plugin@^8
npm i -D @stylistic/eslint-plugin@^4
npm i -D typescript@^5
npm i -D eslint@^10
npm i -D typescript-eslint@^8
npm i -D @stylistic/eslint-plugin@beta
npm i -D typescript@^6
```

Alternatively using bun:

```bash
bun i -D eslint
bun i -D @typescript-eslint/eslint-plugin
bun i -D typescript-eslint
bun i -D @stylistic/eslint-plugin
bun i -D typescript
```

3. Use config in your `eslintrc.js`
3. Use config in your `eslint.config.ts` (Flat Config)

```javascript
module.exports = {
extends: '@terrestris/eslint-config-typescript'
};
const terrestrisConfig = require('@terrestris/eslint-config-typescript');

module.exports = [
...terrestrisConfig,
// your own overrides...
];
```

4. Using eslint v9

First of all, make sure you use a recent node version!

After that, you can use a simple config like this to use this with eslint v9:

```js
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
const compat = new FlatCompat({
baseDirectory: dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [...compat.extends('@terrestris/eslint-config-typescript-react'), {
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsParser,
},
}];
Or using ESM (`eslint.config.mjs`):

```javascript
import terrestrisConfig from '@terrestris/eslint-config-typescript';

export default [
...terrestrisConfig,
// your own overrides...
];
```

## Release
Expand Down
112 changes: 112 additions & 0 deletions eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import tsEslint from 'typescript-eslint';
import stylistic from '@stylistic/eslint-plugin';

const customRules = {
'quote-props': ['warn', 'as-needed'],
'keyword-spacing': 'error',
'@stylistic/indent': ['warn', 2, { SwitchCase: 1 }],
'@stylistic/member-delimiter-style': [
'warn',
{
multiline: {
delimiter: 'semi',
requireLast: true
},
singleline: {
delimiter: 'semi',
requireLast: false
}
}
],
'@stylistic/quotes': ['warn', 'single'],
'@stylistic/semi': ['warn', 'always'],
'@stylistic/type-annotation-spacing': 'warn',
'@typescript-eslint/member-ordering': 'warn',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/naming-convention': [
'warn',
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase']
},
{
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: false
}
}
],
'camelcase': 'warn',
'comma-dangle': 'off',
'curly': 'warn',
'dot-notation': 'warn',
'eol-last': 'warn',
'eqeqeq': ['warn', 'smart'],
'guard-for-in': 'warn',
'id-denylist': [
'warn',
'any',
'Number',
'number',
'String',
'string',
'Boolean',
'boolean',
'Undefined',
'undefined'
],
'id-match': 'warn',
'max-len': ['warn', { code: 120 }],
'no-bitwise': 'warn',
'no-caller': 'warn',
'no-console': 'warn',
'no-debugger': 'warn',
'no-empty': 'warn',
'no-eval': 'warn',
'no-fallthrough': 'warn',
'no-multiple-empty-lines': 'warn',
'no-new-wrappers': 'warn',
'no-redeclare': 'warn',
'no-shadow': ['warn', { hoist: 'all' }],
'no-trailing-spaces': 'warn',
'no-underscore-dangle': ['error', { allowAfterThis: true }],
'no-unused-expressions': 'warn',
'no-unused-labels': 'warn',
'radix': 'warn',
'spaced-comment': 'warn'
};

export default [
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsEslint.parser,
parserOptions: {
projectService: true
},
sourceType: 'module'
},
plugins: {
'@typescript-eslint': tsEslint.plugin,
'@stylistic': stylistic
},
rules: customRules
},
{
files: ['**/*.js', '**/*.jsx'],
plugins: {
'@stylistic': stylistic
},
rules: {
...customRules,
// Disable typescript-specific rules for JS files
'@typescript-eslint/switch-exhaustiveness-check': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/member-ordering': 'off',
'@typescript-eslint/no-explicit-any': 'off'
}
}
];
132 changes: 0 additions & 132 deletions index.js

This file was deleted.

Loading