Skip to content

Commit

Permalink
Merge pull request #105 from planetlabs/sorted-imports
Browse files Browse the repository at this point in the history
Configure import sorting
  • Loading branch information
tschaub authored Jan 9, 2025
2 parents 0c07d15 + e8adf38 commit dcf6e9d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 101 deletions.
2 changes: 1 addition & 1 deletion examples/es6/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import foo from './local-module.js';
import fs from 'fs';
import path from 'path';
import foo from './local-module.js';

const main = paths =>
Promise.all(
Expand Down
2 changes: 1 addition & 1 deletion examples/react/component.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {string} from 'prop-types';
import React, {useCallback, useState} from 'react';
import ReactDOM from 'react-dom';
import {string} from 'prop-types';

const HelloMessage = ({name}) => {
const [greeting, setGreeting] = useState('Hello');
Expand Down
81 changes: 20 additions & 61 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import globals from 'globals';
import importPlugin from 'eslint-plugin-import';
import js from '@eslint/js';
import importPlugin from 'eslint-plugin-import';
import prettier from 'eslint-plugin-prettier';
import sortImportPlugin from 'eslint-plugin-sort-imports-es6-autofix';
import globals from 'globals';

export default [
js.configs.recommended,
Expand All @@ -11,7 +10,6 @@ export default [
name: 'planet/recommended',
plugins: {
prettier,
'sort-imports-es6-autofix': sortImportPlugin,
},

languageOptions: {
Expand All @@ -25,41 +23,13 @@ export default [
},

rules: {
// core rules
'array-callback-return': 'error',
'block-scoped-var': 'error',
curly: 'error',
'default-case': 'error',

'dot-notation': [
'error',
{
allowPattern: '^[a-z]+(_[a-z]+)+$',
},
],

'dot-notation': ['error', {allowPattern: '^[a-z]+(_[a-z]+)+$'}],
eqeqeq: 'error',
'import/default': 'error',

'import/extensions': [
'error',
'always',
{
ignorePackages: true,
},
],

'import/first': 'error',
'import/named': 'error',
'import/no-duplicates': 'error',
'import/no-self-import': 'error',

'import/no-unresolved': [
'error',
{
commonjs: true,
},
],

'no-case-declarations': 'error',
'no-cond-assign': 'error',
'no-console': 'error',
Expand Down Expand Up @@ -94,40 +64,29 @@ export default [
'no-unexpected-multiline': 'error',
'no-unreachable': 'error',
'no-unsafe-finally': 'error',

'no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
},
],

'no-unused-vars': ['error', {ignoreRestSiblings: true}],
'no-use-before-define': ['error', 'nofunc'],
'no-var': 'error',
'prefer-const': 'error',

'prettier/prettier': [
'error',
{
singleQuote: true,
bracketSpacing: false,
arrowParens: 'avoid',
},
],

strict: 'off',
'use-isnan': 'error',
'valid-typeof': 'error',

'sort-imports-es6-autofix/sort-imports-es6': [
// import plugin
'import/default': 'error',
'import/extensions': ['error', 'always', {ignorePackages: true}],
'import/first': 'error',
'import/named': 'error',
'import/no-duplicates': 'error',
'import/no-self-import': 'error',
'import/no-unresolved': ['error', {commonjs: true}],
'import/order': ['error', {named: true, alphabetize: {order: 'asc'}}],

// prettier plugin
'prettier/prettier': [
'error',
{
ignoreCase: false,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'single', 'multiple'],
},
{singleQuote: true, bracketSpacing: false, arrowParens: 'avoid'},
],

'use-isnan': 'error',
'valid-typeof': 'error',
},
},
];
57 changes: 21 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.3",
"eslint-plugin-react-hooks": "5.0.0",
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
"globals": "^15.14.0",
"prettier": "^3.4.2"
}
Expand Down
2 changes: 1 addition & 1 deletion react.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import planetConfig from './index.js';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import planetConfig from './index.js';

export default [
...planetConfig,
Expand Down

0 comments on commit dcf6e9d

Please sign in to comment.