Skip to content

Commit

Permalink
feat: sort eslintConfig (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored and keithamus committed Jan 3, 2020
1 parent c01cbc7 commit eda4a64
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ const sortDirectories = sortObjectBy([
const sortProperty = (property, over) => object =>
Object.assign(object, { [property]: over(object[property]) })
const sortGitHooks = sortObjectBy(gitHooks)
const sortESLintConfig = sortObjectBy([
'env',
'parser',
'parserOptions',
'settings',
'plugins',
'extends',
'rules',
'overrides',
'globals',
'processor',
'noInlineConfig',
'reportUnusedDisableDirectives',
])

// See https://docs.npmjs.com/misc/scripts
const defaultNpmScripts = new Set([
Expand Down Expand Up @@ -132,7 +146,7 @@ const fields = [
{ key: 'browserslist' },
{ key: 'xo', over: sortObject },
{ key: 'prettier', over: sortObject },
{ key: 'eslintConfig', over: sortObject },
{ key: 'eslintConfig', over: sortESLintConfig },
{ key: 'eslintIgnore' },
{ key: 'stylelint' },
{ key: 'ava', over: sortObject },
Expand Down
14 changes: 13 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ for (const field of [
'babel',
'xo',
'prettier',
'eslintConfig',
'ava',
'jest',
'mocha',
Expand Down Expand Up @@ -288,6 +287,19 @@ testField('husky', [
},
])

testField('eslintConfig', [
{
value: {
overrides: [],
extends: ['standard', 'plugin:prettier/recommended', 'prettier/standard'],
[UNKNOWN]: UNKNOWN,
rules: {},
plugins: ['prettier'],
},
expect: ['plugins', 'extends', 'rules', 'overrides', UNKNOWN],
},
])

testField('binary', [
{
value: {
Expand Down

0 comments on commit eda4a64

Please sign in to comment.