diff --git a/index.js b/index.js index 57fef0cd..cc3540be 100755 --- a/index.js +++ b/index.js @@ -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([ @@ -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 }, diff --git a/test.js b/test.js index dffe63b7..ff4858d5 100644 --- a/test.js +++ b/test.js @@ -197,7 +197,6 @@ for (const field of [ 'babel', 'xo', 'prettier', - 'eslintConfig', 'ava', 'jest', 'mocha', @@ -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: {