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

Configure import sorting #105

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]+)+$',
},
],

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left these and the rules below in place. I just organized them into core and plugin groups.

'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
Loading