Skip to content

Commit

Permalink
Add lint rules (except naming) (#321)
Browse files Browse the repository at this point in the history
Should also fix the data credit page

---------

Co-authored-by: Luke Brody <lukebrody@pavonine.co>
Co-authored-by: Kavi Gupta <kavi@berkeley.edu>
  • Loading branch information
3 people committed Sep 7, 2024
1 parent 8868694 commit c3f8449
Show file tree
Hide file tree
Showing 70 changed files with 11,595 additions and 7,946 deletions.
127 changes: 106 additions & 21 deletions react/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,110 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import stylistic from '@stylistic/eslint-plugin'
import comments from 'eslint-plugin-eslint-comments'
import importPlugin from 'eslint-plugin-import'
import tseslint from 'typescript-eslint'
import reactPlugin from "eslint-plugin-react"
import preferFC from 'eslint-plugin-react-prefer-function-component/config'
import reactHooks from 'eslint-plugin-react-hooks'

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
{
files: ['**/*.{ts,tsx,mts,cts}'],
rules: {
'no-undef': 'off',
},
},
{
ignores: ['**/*.js', 'src/utils/protos.d.ts'],
},
{
rules: {
"@typescript-eslint/no-require-imports": ["error", { allow: ['\\.json$']}],
"@typescript-eslint/no-non-null-assertion": "off"
}
}
);
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
reactPlugin.configs.flat.recommended,
{
settings: {
react: {
version: 'detect',
},
}
},
preferFC.configs.recommended,
{
plugins: {
'react-hooks': reactHooks
},
rules: reactHooks.configs.recommended.rules
},
stylistic.configs.customize({
indent: 4,
}),
{
plugins: {
import: importPlugin,
},
rules: {
...importPlugin.configs.recommended.rules,
...importPlugin.configs.recommended.typescript,
'import/order': ['error', {
'alphabetize': {
order: 'asc',
},
'newlines-between': 'always',
}],
'import/no-unassigned-import': ['error', {
allow: ['**/*.css'],
}],
'import/no-named-as-default-member': 'off',
'import/namespace': 'off',
},
settings: {
'import/resolver': {
typescript: true,
node: true,
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
},
},
{
plugins: { 'eslint-comments': comments },
rules: comments.configs.recommended.rules,
},
{
files: ['**/*.{ts,tsx,mts,cts}'],
rules: {
'no-undef': 'off',
},
},
{
ignores: ['**/*.{js,mjs}', 'src/utils/protos.d.ts'],
},
{
rules: {
'@typescript-eslint/no-require-imports': ['error', { allow: ['\\.json$'] }],
'@typescript-eslint/no-non-null-assertion': 'off',
'prefer-template': 'error',
'@typescript-eslint/restrict-template-expressions': 'off',
'eslint-comments/no-unused-disable': 'error',
'no-console': ['error', { "allow": ["warn", "error"] }],
'@stylistic/max-statements-per-line': 'off',
'@typescript-eslint/no-unnecessary-condition': ['error', { allowConstantLoopConditions: true }],
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
'@typescript-eslint/no-misused-promises': ['error', {
checksVoidReturn: {
attributes: false,
arguments: false,
},
}],
'eqeqeq': 'error',
'guard-for-in': 'error',
'object-shorthand': 'error',
'no-restricted-syntax': ['error', 'ExportNamedDeclaration:not([declaration])'],
'react/prop-types': 'off',
'no-shadow': 'error',
'eslint-comments/require-description': ['error', {
ignore: ['eslint-enable']
}],
},
},
{
languageOptions: {
parserOptions: {
parser: '@typescript-eslint/parser',
project: true,
},
},
},
)
Loading

0 comments on commit c3f8449

Please sign in to comment.