diff --git a/packages/eslint-config-humanmade/fixtures/fail/import-order.js b/packages/eslint-config-humanmade/fixtures/fail/import-order.js new file mode 100644 index 00000000..beb2d9d3 --- /dev/null +++ b/packages/eslint-config-humanmade/fixtures/fail/import-order.js @@ -0,0 +1,11 @@ +/* eslint-disable no-unused-vars */ + +import apiFetch from '@wordpress/api-fetch'; +import chalk from 'chalk'; +import eslint from 'eslint'; +import path from 'path'; +import './'; +import Test from './component-jsx-parentheses'; +import './style.scss'; +import index from '../../index'; +import '../test-lint-config'; diff --git a/packages/eslint-config-humanmade/fixtures/pass/import-order.js b/packages/eslint-config-humanmade/fixtures/pass/import-order.js new file mode 100644 index 00000000..28f2663d --- /dev/null +++ b/packages/eslint-config-humanmade/fixtures/pass/import-order.js @@ -0,0 +1,16 @@ +/* eslint-disable no-unused-vars */ + +import path from 'path'; + +import chalk from 'chalk'; +import eslint from 'eslint'; + +import apiFetch from '@wordpress/api-fetch'; + +import index from '../../index'; +import '../test-lint-config'; + +import Test from './component-jsx-parentheses'; + +import './'; +import './style.scss'; diff --git a/packages/eslint-config-humanmade/index.js b/packages/eslint-config-humanmade/index.js index f61e53cd..242bcf25 100644 --- a/packages/eslint-config-humanmade/index.js +++ b/packages/eslint-config-humanmade/index.js @@ -7,6 +7,7 @@ module.exports = { 'extends': [ 'eslint:recommended', 'react-app', + 'plugin:import/errors', 'plugin:jsdoc/recommended', 'plugin:react-hooks/recommended', ], @@ -40,6 +41,23 @@ module.exports = { 'eol-last': [ 'error', 'unix' ], 'eqeqeq': [ 'error' ], 'func-call-spacing': [ 'error' ], + 'import/no-unresolved': [ 'off' ], + 'import/order': [ 'error', { + 'alphabetize': { + 'order': 'asc', + 'caseInsensitive': true + }, + 'groups': [ 'builtin', 'external', 'parent', 'sibling', 'index' ], + 'newlines-between': 'always', + 'pathGroups': [ + { + 'pattern': '@wordpress/**', + 'group': 'external', + 'position': 'after' + } + ], + 'pathGroupsExcludedImportTypes': [ 'builtin' ] + } ], 'indent': [ 'error', 'tab', { 'SwitchCase': 1, } ],