Skip to content

Commit eda4a64

Browse files
fiskerkeithamus
authored andcommittedJan 3, 2020
feat: sort eslintConfig (#116)
1 parent c01cbc7 commit eda4a64

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed
 

‎index.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ const sortDirectories = sortObjectBy([
2626
const sortProperty = (property, over) => object =>
2727
Object.assign(object, { [property]: over(object[property]) })
2828
const sortGitHooks = sortObjectBy(gitHooks)
29+
const sortESLintConfig = sortObjectBy([
30+
'env',
31+
'parser',
32+
'parserOptions',
33+
'settings',
34+
'plugins',
35+
'extends',
36+
'rules',
37+
'overrides',
38+
'globals',
39+
'processor',
40+
'noInlineConfig',
41+
'reportUnusedDisableDirectives',
42+
])
2943

3044
// See https://docs.npmjs.com/misc/scripts
3145
const defaultNpmScripts = new Set([
@@ -132,7 +146,7 @@ const fields = [
132146
{ key: 'browserslist' },
133147
{ key: 'xo', over: sortObject },
134148
{ key: 'prettier', over: sortObject },
135-
{ key: 'eslintConfig', over: sortObject },
149+
{ key: 'eslintConfig', over: sortESLintConfig },
136150
{ key: 'eslintIgnore' },
137151
{ key: 'stylelint' },
138152
{ key: 'ava', over: sortObject },

‎test.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ for (const field of [
197197
'babel',
198198
'xo',
199199
'prettier',
200-
'eslintConfig',
201200
'ava',
202201
'jest',
203202
'mocha',
@@ -288,6 +287,19 @@ testField('husky', [
288287
},
289288
])
290289

290+
testField('eslintConfig', [
291+
{
292+
value: {
293+
overrides: [],
294+
extends: ['standard', 'plugin:prettier/recommended', 'prettier/standard'],
295+
[UNKNOWN]: UNKNOWN,
296+
rules: {},
297+
plugins: ['prettier'],
298+
},
299+
expect: ['plugins', 'extends', 'rules', 'overrides', UNKNOWN],
300+
},
301+
])
302+
291303
testField('binary', [
292304
{
293305
value: {

0 commit comments

Comments
 (0)
Please sign in to comment.