Skip to content

Commit

Permalink
Merge pull request #600 from fishbrain/add-non-typescript-option
Browse files Browse the repository at this point in the history
Add config for plain JS
  • Loading branch information
lhansford authored Oct 28, 2024
2 parents f181402 + 9b5d4fb commit 2e350bf
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Create a file in the root of your project named `eslint.config.js`, or `eslint.c
Populate it with the following content:

```js
import { config, looseTypes, configWithoutJest } from '@fishbrain/eslint-config-base';
import { config, looseTypes, configWithoutJest, configWithoutTypescript } from '@fishbrain/eslint-config-base';

export default [
...config, // or configWithoutJest if the project doesn't use Jest.
...config, // or configWithoutJest or configWithoutTypescript depending on the needs of the project.
...looseTypes, // Use this if the project is poorly typed.
];
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@fishbrain/eslint-config-monorepo",
"private": true,
"description": "ESLint configs for Fishbrain projects",
"version": "6.1.0",
"version": "6.1.1",
"workspaces": [
"packages/*"
],
Expand Down
34 changes: 25 additions & 9 deletions packages/base/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ const baseConfig = [
];

const customRules = {
rules: {
curly: ['error', 'all'],
'max-lines': ['error', { max: 300, skipComments: true }],
'no-magic-numbers': [
'error',
{ ignoreArrayIndexes: true, ignore: ALLOWED_NUMBERS },
],
'prettier/prettier': 'error',
'require-atomic-updates': 'error',
},
};

const customRulesTypescript = {
rules: {
'@typescript-eslint/no-empty-function': 'off', // Noop functions are a common pattern we use during testing, so we don't want to enable it.
'@typescript-eslint/no-explicit-any': ['error', { fixToUnknown: true }],
Expand All @@ -54,23 +67,26 @@ const customRules = {
allowNumber: true,
},
],
curly: ['error', 'all'],
'max-lines': ['error', { max: 300, skipComments: true }],
'no-magic-numbers': [
'error',
{ ignoreArrayIndexes: true, ignore: ALLOWED_NUMBERS },
],
'prettier/prettier': 'error',
'require-atomic-updates': 'error',
},
};

export const configWithoutJest = tseslint.config(...baseConfig, customRules);
export const configWithoutTypescript = [
...baseConfig,
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
jestPlugin.configs['flat/recommended'],
customRules,
];
export const configWithoutJest = tseslint.config(
...baseConfig,
customRules,
customRulesTypescript,
);
export const config = tseslint.config(
...baseConfig,
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
jestPlugin.configs['flat/recommended'],
customRules,
customRulesTypescript,
);

/* Use this if your project is not well typed yet (e.g. lots of `any` types). Ideally you should not use this, but in some cases it may be necessary. */
Expand Down
2 changes: 1 addition & 1 deletion packages/base/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@fishbrain/eslint-config-base",
"packageManager": "[email protected]",
"version": "6.1.0",
"version": "6.1.1",
"type": "module",
"exports": "./index.js",
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions packages/react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ const customRules = {
},
};

export const configWithoutTypescript = [
...baseConfig,
...reactConfig,
...testingConfig,
customRules,
];

export const config = tseslint.config(
...baseConfig,
...reactConfig,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@fishbrain/eslint-config-react",
"packageManager": "[email protected]",
"version": "6.1.0",
"version": "6.1.1",
"type": "module",
"exports": "./index.js",
"scripts": {
Expand Down

0 comments on commit 2e350bf

Please sign in to comment.