Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import rules, groupings, and order enforced by lint #7094

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

drewvolz
Copy link
Member

@drewvolz drewvolz commented Oct 21, 2023

Closes #7093

Import rules to take into account:

  • Imports come first
  • No duplicates

Import groupings to ensure:

  1. Node built-ins
  2. Packages. react related packages come first.
  3. react-native-* community packages
  4. React navigation
  5. Internal packages and scopes
  6. Side effect imports.
  7. Parent imports. Put .. last.
  8. Other relative imports. Put same-folder imports and . last.
  9. Style imports.
  10. Image imports

Room for improvement here, plenty of room for feedback.

.eslintrc.yaml Show resolved Hide resolved
.eslintrc.yaml Show resolved Hide resolved
.eslintrc.yaml Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 22, 2023

Codecov Report

Merging #7094 (9c42fc1) into master (d32030b) will not change coverage.
The diff coverage is 0.00%.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #7094   +/-   ##
======================================
  Coverage    8.47%   8.47%           
======================================
  Files         306     306           
  Lines        5225    5225           
  Branches     1404    1404           
======================================
  Hits          443     443           
  Misses       4755    4755           
  Partials       27      27           

@hawkrives
Copy link
Member

@drewvolz This is what we have for the import plugin:

'import/extensions': ['error', { js: 'never', jsx: 'never', json: 'always', ts: 'never', tsx: 'never' }],
		'import/named': 'error',
		'import/no-cycle': 'off',
		'import/no-namespace': 'warn',
		'import/no-restricted-paths': ['warn', { zones: [{ target: './test', from: './app/actions' }] }],
		'import/no-self-import': 'error',
		'import/order': [
			'warn',
			{
				groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
				'newlines-between': 'never',
				alphabetize: { order: 'asc', caseInsensitive: true },
			},
		],
		'import/prefer-default-export': 'off',

and

{
			files: ['test/**'],
			env: { node: true },
			extends: ['plugin:@typescript-eslint/recommended-type-checked', 'plugin:@typescript-eslint/stylistic'],
			rules: {
				'import/no-extraneous-dependencies': ['error', { devDependencies: true }],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable eslint-plugin-imports
3 participants