Skip to content

Commit

Permalink
feat(lint): unify configuration for linting tools (#21)
Browse files Browse the repository at this point in the history
* feat(lint): unify configuration for linting tools

* feat(lint): unify configuration for linting tools
  • Loading branch information
david-gomey authored Sep 2, 2024
1 parent a5b22ef commit 0b634e3
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 49 deletions.
1 change: 0 additions & 1 deletion sample/src/components/counter/Counter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useCounter } from '../../hooks/useCounter';

import { StyledButton, StyledCounter } from './Counter.styles';

export function Counter() {
Expand Down
3 changes: 1 addition & 2 deletions sample/src/containers/welcome/Welcome.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { WelcomeProps } from './Welcome.types';

import { StyledWelcome } from './Welcome.styles';
import { WelcomeProps } from './Welcome.types';

export function Welcome({ children, message = 'Welcome!' }: WelcomeProps) {
return (
Expand Down
1 change: 0 additions & 1 deletion sample/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { StrictMode } from 'react';
import ReactDOM from 'react-dom/client';

import { App } from './App';

import './styles/index.css';

ReactDOM.createRoot(document.getElementById('root')!).render(
Expand Down
1 change: 0 additions & 1 deletion sample/src/pages/home-page/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Counter } from '../../components/counter';
import { Welcome } from '../../containers/welcome';

import { StyledHomePage } from './HomePage.styles';

export function HomePage() {
Expand Down
3 changes: 2 additions & 1 deletion sample/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';

import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
Expand Down
126 changes: 94 additions & 32 deletions src/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,116 @@ module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true,
es6: true,
jest: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:jest/recommended',
'plugin:prettier/recommended',
'plugin:react/recommended',
'prettier',
'plugin:react-hooks/recommended',
],
globals: {
Landbot: false,
LandbotFrameWidget: false,
LandbotFullpage: false,
__dirname: false,
process: false,
},
ignorePatterns: [
'src/plugin/*',
'babel.config.js',
'prettier.config.js',
'commitlint.config.js',
'.eslintrc.js',
'LOCAL_SETTINGS.js',
],
overrides: [
{
files: ['./src/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-empty-interface': [
'error',
{
allowSingleExtends: true,
},
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'no-unused-vars': 'off',
'no-undef-init': 'warn',
},
},
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
ecmaVersion: 2018,
project: './tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'check-file', 'import', 'jest', 'prettier', 'react'],
plugins: ['react', '@typescript-eslint', 'prettier', 'import', 'jest'],
root: true,
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'check-file/folder-naming-convention': ['error', { 'src/**/': 'KEBAB_CASE' }],
'check-file/folder-match-with-fex': [
'@typescript-eslint/no-unused-vars': [
'error',
{
'*.test.{js,jsx,ts,tsx}': '!**/__tests__/',
'*.test.{js,jsx,ts,tsx}': '!**/__test__/',
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'import/no-default-export': 'off',
'prettier/prettier': ['error', require('./.prettierrc.js')],
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
},
overrides: [
{
files: ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.js', 'src/**/*.jsx'],
rules: {
'import/no-default-export': 'error',
'import/no-extraneous-dependencies': 'off',
'linebreak-style': 'off',
'no-console': 'error',
'no-restricted-imports': [
'error',
{
paths: [
{
importNames: ['default', 'pricing'],
message:
"Please use the context 'usePricingContext' from 'src/context' instead of the instance from 'core/pricing'.",
name: 'core/pricing',
},
{
importNames: ['default'],
message:
"Please use the context 'useSettingsContext' from 'src/context' instead of the instance from 'core/SETTINGS'.",
name: 'core/SETTINGS',
},
{
importNames: ['faker'],
message: "Please import { faker } from '@faker-js/faker/locale/en' instead due to performance issues",
name: '@faker-js/faker',
},
{
message: "Please use more specific import: import format from 'date-fns/format'",
name: 'date-fns',
},
],
patterns: [
{
group: ['analytics.legacy', './analytics.legacy'],
message: "Please import analytics from 'core/analytics' instead",
},
],
},
},
],
settings: {
react: {
version: 'detect',
},
],
'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
],
},
};
12 changes: 1 addition & 11 deletions src/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 120,
tabWidth: 2,
endOfLine: 'lf',
plugins: [require.resolve('@trivago/prettier-plugin-sort-imports')],
importOrder: [
'^(react|react-dom(.*))$',
'<THIRD_PARTY_MODULES>',
'@/(.*)',
'^[./].*(?<!(\\.(c|le|sc)ss|styles))$',
'\\.((c|le|sc)ss|styles)$',
],
importOrder: ['^@(.*)$', '^[a-zA-Z]*/(.*)$', '^[./]'],
importOrderSeparation: true,
importOrderSortSpecifiers: true,
};

0 comments on commit 0b634e3

Please sign in to comment.