Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
lhansford committed Aug 30, 2024
1 parent bf8b1a4 commit 20cf521
Show file tree
Hide file tree
Showing 18 changed files with 580 additions and 549 deletions.
33 changes: 0 additions & 33 deletions .eslintrc.js

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on:
push:
branches-ignore:
- master
- main

jobs:
test:
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Install
run: yarn

- name: Test
- name: Test configs
run: yarn test
env:
CI: true
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish
on:
push:
branches:
- master
- main

jobs:
publish:
Expand Down
64 changes: 1 addition & 63 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,64 +1,2 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

# Yarn
node_modules
.yarn
18 changes: 1 addition & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,9 @@ You can also add exceptions for polyfills in `.eslintrc`. See
}
```

### Editor settings

To enable ESLint in VS Code add the following to your `settings.json`:

```json
{
"tslint.enable": false,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
]
}
```

## Releasing

1. Update the version number in package.json
1. Run `yarn version <patch|minor|major>`.
2. Merge all changes to `develop`
3. Run `/golive eslint-config-fishbrain` in Slack.
4. Merge the created go live PR.
2 changes: 0 additions & 2 deletions index.js

This file was deleted.

31 changes: 8 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"name": "eslint-config-fishbrain",
"version": "5.0.6",
"description": "ESLint config for Fishbrain TypeScript projects",
"main": "index.js",
"scripts": {
"test": "eslint --no-ignore .eslintrc.js"
},
"name": "@eslint-config-fishbrain/monorepo",
"description": "ESLint configs for Fishbrain projects",
"version": "6.0.0",
"workspaces": [
"packages/*"
],
"repository": {
"type": "git",
"url": "git+https://github.com/fishbrain/eslint-config-fishbrain.git"
Expand All @@ -16,22 +15,8 @@
"url": "https://github.com/fishbrain/eslint-config-fishbrain/issues"
},
"homepage": "https://github.com/fishbrain/eslint-config-fishbrain#readme",
"devDependencies": {
"jest": "^29.7.0",
"react": "^18.2.0",
"typescript": "^5.2.2"
},
"peerDependencies": {
"react": "^18.2.0"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"eslint-config-fishbrain-base": "^5.0.5",
"eslint-plugin-compat": "^4.2.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0"
"scripts": {
"test": "yarn workspaces foreach --all run test"
},
"prettier": {
"singleQuote": true,
Expand Down
1 change: 1 addition & 0 deletions packages/base/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# base
171 changes: 171 additions & 0 deletions packages/base/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import jestPlugin from 'eslint-plugin-jest';
import prettierPlugin from 'eslint-plugin-prettier';

const HTTP_CODES = [200, 201, 204, 301, 302, 400, 401, 404, 422, 500];
const HTML_HEADER_LEVELS = [1, 2, 3, 4, 5, 6];
const COMMON_MATH_VALUES = [24, 60, 100];
const COMMON_INDEX_VALUES = [-1, 0, 1];
const ALLOWED_NUMBERS = Array.from(
new Set(
COMMON_INDEX_VALUES.concat(
HTTP_CODES,
HTML_HEADER_LEVELS,
COMMON_MATH_VALUES,
),
),
);

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
jestPlugin.configs['flat/recommended'],
{
plugins: { prettier: prettierPlugin },
rules: {
// Core rules replaced by Typescript rules
'no-use-before-define': 'off',
'consistent-return': 'off', // TypeScript takes care of checking return
// 'import/no-unresolved': 'off', // Doesn't work properly with TypeScript // TODO:
'no-extra-parens': 'off',

// Additional Fishbrain rules
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-ignore': 'off',
// This rule required so many exceptions that it was getting difficult to maintain. So
// just name things sensibly :)
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
// Noop functions are a common pattern we use during testing, so we don't want to enable it.
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': ['error', { fixToUnknown: true }],
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' },
],
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/triple-slash-reference': [
'error',
{ types: 'prefer-import' },
],
'@typescript-eslint/prefer-readonly': 'error',

// Warns if a type assertion does not change the type of an expression
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md
'@typescript-eslint/no-unnecessary-type-assertion': 'error',

// Enforce includes method over indexOf method
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-includes.md
'@typescript-eslint/prefer-includes': 'error',

// Enforce the use of String#startsWith and String#endsWith instead of other equivalent methods of checking substrings
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md
'@typescript-eslint/prefer-string-starts-ends-with': 'error',

curly: ['error', 'all'],

// 'fp/no-delete': 'error',
// 'fp/no-let': 'error',
// 'fp/no-loops': 'error',
// 'fp/no-mutating-assign': 'error',
// 'fp/no-mutation': [
// 'error',
// {
// allowThis: true,
// },
// ],
// TODO:
// 'import/named': 'off', // Redundant when used with Typescript.
// 'import/no-extraneous-dependencies': [
// 'error',
// {
// devDependencies: [
// '**/*.test.tsx',
// '**/*.test.ts',
// '**/testing.tsx',
// '**/*.stories.tsx',
// '**/*.stories.ts',
// '**/setupTests.ts',
// '**/webpack.config.{js,ts}', // webpack config
// '**/webpack.config.*.{js,ts}', // webpack config
// ],
// },
// ],
// 'import/order': [
// 'error',
// {
// 'newlines-between': 'always-and-inside-groups',
// groups: [
// ['builtin', 'external'],
// ['internal', 'sibling', 'parent', 'index'],
// ],
// },
// ],
// 'import/prefer-default-export': 'off',
// // Allow typescript imports, airbnb has disallowed it
// 'import/extensions': [
// 'error',
// 'ignorePackages',
// {
// js: 'never',
// jsx: 'never',
// ts: 'never',
// tsx: 'never',
// },
// ],
'max-lines': ['error', { max: 300, skipComments: true }],

// Disallow Magic Numbers
// https://eslint.org/docs/rules/no-magic-numbers
'no-magic-numbers': [
'error',
{ ignoreArrayIndexes: true, ignore: ALLOWED_NUMBERS },
],

// disallow the use of console
// https://eslint.org/docs/rules/no-console
'no-console': 'off',
'prettier/prettier': 'error',

// Disallow assignments that can lead to race conditions due to usage of await or yield
// https://eslint.org/docs/rules/require-atomic-updates
'require-atomic-updates': 'error',

// no export from test file
// https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/no-export.md
// 'jest/no-export': 'error',

// TODO: Below is the "recommended" rules from eslint-plugin-import
// analysis/correctness
// 'import/no-unresolved': 'error', // TODO: dupe
// 'import/named': 'error', // TODO: dupe
// 'import/namespace': 'error',
// 'import/default': 'error',
// 'import/export': 'error',

// // red flags (thus, warnings)
// 'import/no-named-as-default': 'off', // TODO: Should error, but it doesn't work with eslint9 just yet.
// 'import/no-named-as-default-member': 'off', // TODO: Should error, but it doesn't work with eslint9 just yet.
// 'import/no-duplicates': 'warn',
},
},
);
25 changes: 25 additions & 0 deletions packages/base/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@eslint-config-fishbrain/base",
"packageManager": "[email protected]",
"type": "module",
"scripts": {
"test": "eslint --no-ignore eslint.config.js"
},
"dependencies": {
"@eslint/js": "^9.9.1",
"eslint": "^9.9.1",
"eslint-plugin-fp": "^2.3.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.8.0",
"eslint-plugin-prettier": "^5.2.1",
"prettier": "^3.3.3",
"typescript-eslint": "^8.3.0"
},
"peerDependencies": {
"typescript": "^5.5.4"
},
"devDependencies": {
"@types/eslint__js": "^8.42.3",
"jest": "^29.7.0"
}
}
Loading

0 comments on commit 20cf521

Please sign in to comment.