Skip to content

Commit dcf6e9d

Browse files
authored
Merge pull request #105 from planetlabs/sorted-imports
Configure import sorting
2 parents 0c07d15 + e8adf38 commit dcf6e9d

File tree

6 files changed

+44
-101
lines changed

6 files changed

+44
-101
lines changed

examples/es6/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import foo from './local-module.js';
21
import fs from 'fs';
32
import path from 'path';
3+
import foo from './local-module.js';
44

55
const main = paths =>
66
Promise.all(

examples/react/component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import {string} from 'prop-types';
12
import React, {useCallback, useState} from 'react';
23
import ReactDOM from 'react-dom';
3-
import {string} from 'prop-types';
44

55
const HelloMessage = ({name}) => {
66
const [greeting, setGreeting] = useState('Hello');

index.js

Lines changed: 20 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import globals from 'globals';
2-
import importPlugin from 'eslint-plugin-import';
31
import js from '@eslint/js';
2+
import importPlugin from 'eslint-plugin-import';
43
import prettier from 'eslint-plugin-prettier';
5-
import sortImportPlugin from 'eslint-plugin-sort-imports-es6-autofix';
4+
import globals from 'globals';
65

76
export default [
87
js.configs.recommended,
@@ -11,7 +10,6 @@ export default [
1110
name: 'planet/recommended',
1211
plugins: {
1312
prettier,
14-
'sort-imports-es6-autofix': sortImportPlugin,
1513
},
1614

1715
languageOptions: {
@@ -25,41 +23,13 @@ export default [
2523
},
2624

2725
rules: {
26+
// core rules
2827
'array-callback-return': 'error',
2928
'block-scoped-var': 'error',
3029
curly: 'error',
3130
'default-case': 'error',
32-
33-
'dot-notation': [
34-
'error',
35-
{
36-
allowPattern: '^[a-z]+(_[a-z]+)+$',
37-
},
38-
],
39-
31+
'dot-notation': ['error', {allowPattern: '^[a-z]+(_[a-z]+)+$'}],
4032
eqeqeq: 'error',
41-
'import/default': 'error',
42-
43-
'import/extensions': [
44-
'error',
45-
'always',
46-
{
47-
ignorePackages: true,
48-
},
49-
],
50-
51-
'import/first': 'error',
52-
'import/named': 'error',
53-
'import/no-duplicates': 'error',
54-
'import/no-self-import': 'error',
55-
56-
'import/no-unresolved': [
57-
'error',
58-
{
59-
commonjs: true,
60-
},
61-
],
62-
6333
'no-case-declarations': 'error',
6434
'no-cond-assign': 'error',
6535
'no-console': 'error',
@@ -94,40 +64,29 @@ export default [
9464
'no-unexpected-multiline': 'error',
9565
'no-unreachable': 'error',
9666
'no-unsafe-finally': 'error',
97-
98-
'no-unused-vars': [
99-
'error',
100-
{
101-
ignoreRestSiblings: true,
102-
},
103-
],
104-
67+
'no-unused-vars': ['error', {ignoreRestSiblings: true}],
10568
'no-use-before-define': ['error', 'nofunc'],
10669
'no-var': 'error',
10770
'prefer-const': 'error',
108-
109-
'prettier/prettier': [
110-
'error',
111-
{
112-
singleQuote: true,
113-
bracketSpacing: false,
114-
arrowParens: 'avoid',
115-
},
116-
],
117-
11871
strict: 'off',
72+
'use-isnan': 'error',
73+
'valid-typeof': 'error',
11974

120-
'sort-imports-es6-autofix/sort-imports-es6': [
75+
// import plugin
76+
'import/default': 'error',
77+
'import/extensions': ['error', 'always', {ignorePackages: true}],
78+
'import/first': 'error',
79+
'import/named': 'error',
80+
'import/no-duplicates': 'error',
81+
'import/no-self-import': 'error',
82+
'import/no-unresolved': ['error', {commonjs: true}],
83+
'import/order': ['error', {named: true, alphabetize: {order: 'asc'}}],
84+
85+
// prettier plugin
86+
'prettier/prettier': [
12187
'error',
122-
{
123-
ignoreCase: false,
124-
ignoreMemberSort: false,
125-
memberSyntaxSortOrder: ['none', 'all', 'single', 'multiple'],
126-
},
88+
{singleQuote: true, bracketSpacing: false, arrowParens: 'avoid'},
12789
],
128-
129-
'use-isnan': 'error',
130-
'valid-typeof': 'error',
13190
},
13291
},
13392
];

package-lock.json

Lines changed: 21 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"eslint-plugin-prettier": "^5.2.1",
3333
"eslint-plugin-react": "^7.37.3",
3434
"eslint-plugin-react-hooks": "5.0.0",
35-
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
3635
"globals": "^15.14.0",
3736
"prettier": "^3.4.2"
3837
}

react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import planetConfig from './index.js';
21
import react from 'eslint-plugin-react';
32
import reactHooks from 'eslint-plugin-react-hooks';
3+
import planetConfig from './index.js';
44

55
export default [
66
...planetConfig,

0 commit comments

Comments
 (0)