Skip to content

Commit

Permalink
Merge pull request #33 from TaitoUnited/chore/linter-and-prettier
Browse files Browse the repository at this point in the history
Linter and Prettier added back 🔎
  • Loading branch information
JulienTexier authored Nov 25, 2024
2 parents 8048ec4 + 0cfbad2 commit 1a3cb87
Show file tree
Hide file tree
Showing 56 changed files with 3,769 additions and 532 deletions.
5 changes: 4 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ src/locales/**/*.js
src/graphql/generated.ts
src/app/playground/
src/components/playground/
src/design-system/
src/design-system/
/.expo
node_modules
.eslintrc.js
158 changes: 0 additions & 158 deletions .eslintrc

This file was deleted.

142 changes: 142 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// https://docs.expo.dev/guides/using-eslint/
module.exports = {
extends: [
// Base configurations
'expo',
'@react-native',
'eslint:recommended',
'prettier',

// React and TypeScript
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/jsx-runtime',

// Accessibility, Localization, and Utility Libraries
'plugin:lingui/recommended',
'plugin:react-native-a11y/ios',
'plugin:lodash/recommended',
],
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
'react',
'lodash',
'lingui',
'simple-import-sort',
'prettier',
],
rules: {
// Formatting and style
'prettier/prettier': 'error',

// General JavaScript rules
'no-use-before-define': 'off', // Disabled due to TypeScript rules
'no-var': 'error', // Enforce modern `let` and `const`
'dot-notation': 'warn', // Prefer dot notation where possible

// TypeScript-specific rules
'@typescript-eslint/ban-ts-comment': 'off', // Allow `@ts-ignore` comments
'@typescript-eslint/no-var-requires': 'off', // Allow `require` usage
'@typescript-eslint/explicit-function-return-type': 'off', // Allow function return to not be typed
'@typescript-eslint/no-use-before-define': 'off', // Allow variable declaration before usage
'@typescript-eslint/no-explicit-any': 'warn', // Allow `any` type
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_' },
],
// Enforce consistent type imports
'@typescript-eslint/consistent-type-imports': [
'error',
{ fixStyle: 'inline-type-imports' },
],

// Import/export rules
'import/namespace': ['error', { allowComputed: true }], // Enforces names exist at the time they are dereferenced, but allowing computed namespace member reference
// Enforce consistent import order
'import/order': [
'error',
{
pathGroups: [
{
pattern: '{~*,~*/**}',
group: 'internal',
position: 'after',
},
],
groups: [
['builtin', 'external', 'internal'],
['parent', 'sibling', 'index'],
],
'newlines-between': 'always',
},
],

// React-specific rules
'react/prop-types': 'off', // Not using PropTypes with TypeScript
'react-hooks/rules-of-hooks': 'error', // Enforce correct Hook usage
'react-hooks/exhaustive-deps': 'warn', // Check effect dependencies

// Lodash-specific rules
'lodash/import-scope': 'error', // Enforce scoped imports
'lodash/prefer-lodash-method': 'off', // Prevents forcing Lodash methods over Native methods
'lodash/prefer-lodash-typecheck': 'off', // Prevents forcing Lodash methods over Native methods
'lodash/prefer-constant': 'off', // Prevents forcing Lodash methods over Native methods
'lodash/prefer-noop': 'off', // Prevents forcing Lodash methods over Native methods
'lodash/prop-shorthand': 'off', // Prevents the use of the _ callback shorthand

// Lingui localization rules
'lingui/no-unlocalized-strings': [
// Ensures that all string literals, templates, and JSX text are wrapped using <Trans>, t, or msg for localization
'error',
{
ignore: [
// Ignore strings that don’t match specific patterns
'^(?![A-Z].*|\\w+\\s\\w+).+$', // Non-uppercase or single-word strings
'^[A-Z0-9_-]+$', // Ignore UPPERCASE strings
],
ignoreNames: [
{ regex: { pattern: 'className', flags: 'i' } },
{ regex: { pattern: '^[A-Z0-9_-]+$' } }, // Ignore UPPERCASE names
'targetName',
'styleName',
'src',
'srcSet',
'type',
'id',
'width',
'height',
'displayName',
'Authorization',
],
ignoreFunctions: [
'styled',
'cva',
'cn',
'track',
'Error',
'console.*',
'*headers.set',
'*.addEventListener',
'*.removeEventListener',
'*.postMessage',
'*.getElementById',
'*.dispatch',
'*.commit',
'*.includes',
'*.indexOf',
'*.endsWith',
'*.startsWith',
'require',
'useState',
],
},
],

// Accessibility rules
// Custom accessibility rules for React Native (provided by react-native-a11y plugin)
},

ignorePatterns: ['/dist/*', '*.d.ts'],
};
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.jpg';
declare module '*.png';
declare module '*.svg';
declare module '*.ttf';
Loading

0 comments on commit 1a3cb87

Please sign in to comment.