@sequencemedia/eslint-config-standard 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ export function isString (v) {
2
+ return typeof v === 'string'
3
+ }
4
+
5
+ export function isObject (v) {
6
+ return (
7
+ (v || false).constructor === Object &&
8
+ !Array.isArray(v)
9
+ )
10
+ }
@@ -0,0 +1,59 @@
1
+ export function getLanguageOptions ({ languageOptions = {} }) {
2
+ return languageOptions
3
+ }
4
+
5
+ export function getLinterOptions ({ linterOptions = {} }) {
6
+ return linterOptions
7
+ }
8
+
9
+ export function getProcessor ({ processor = {} }) {
10
+ return processor
11
+ }
12
+
13
+ export function getRules ({ rules = {} }) {
14
+ return rules
15
+ }
16
+
17
+ export function getSettings ({ settings = {} }) {
18
+ return settings
19
+ }
20
+
21
+ export function mergeLanguageOptions (alpha = {}, omega = {}) {
22
+ return (
23
+ Object
24
+ .assign(
25
+ structuredClone(getLanguageOptions(alpha)),
26
+ getLanguageOptions(omega)
27
+ )
28
+ )
29
+ }
30
+
31
+ export function mergeLinterOptions (alpha = {}, omega = {}) {
32
+ return (
33
+ Object
34
+ .assign(
35
+ structuredClone(getLinterOptions(alpha)),
36
+ getLinterOptions(omega)
37
+ )
38
+ )
39
+ }
40
+
41
+ export function mergeRules (alpha = {}, omega = {}) {
42
+ return (
43
+ Object
44
+ .assign(
45
+ structuredClone(getRules(alpha)),
46
+ getRules(omega)
47
+ )
48
+ )
49
+ }
50
+
51
+ export function mergeSettings (alpha = {}, omega = {}) {
52
+ return (
53
+ Object
54
+ .assign(
55
+ structuredClone(getSettings(alpha)),
56
+ getSettings(omega)
57
+ )
58
+ )
59
+ }
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import standard from './config/standard.mjs'
2
- import stylistic from './config/stylistic.mjs'
1
+ import standard from '#eslint-config-standard/config/standard'
2
+ import stylistic from '#eslint-config-standard/config/stylistic'
3
3
 
4
4
  export default [
5
5
  {
@@ -0,0 +1,38 @@
1
+ import standard from '#eslint-config-standard/config/standard'
2
+
3
+ import {
4
+ mergeLanguageOptions,
5
+ mergeLinterOptions,
6
+ mergeRules,
7
+ mergeSettings
8
+ } from '#eslint-config-standard/common/merge'
9
+
10
+ /**
11
+ * name - A name for the configuration object. This is used in error messages and config inspector to help identify which configuration object is being used. (Naming Convention)
12
+ * files - An array of glob patterns indicating the files that the configuration object should apply to. If not specified, the configuration object applies to all files matched by any other configuration object.
13
+ * ignores - An array of glob patterns indicating the files that the configuration object should not apply to. If not specified, the configuration object applies to all files matched by files. If ignores is used without any other keys in the configuration object, then the patterns act as global ignores.
14
+ * languageOptions - An object containing settings related to how JavaScript is configured for linting.
15
+ * - ecmaVersion - The version of ECMAScript to support. May be any year (i.e., 2022) or version (i.e., 5). Set to "latest" for the most recent supported version. (default: "latest")
16
+ * - sourceType - The type of JavaScript source code. Possible values are "script" for traditional script files, "module" for ECMAScript modules (ESM), and "commonjs" for CommonJS files. (default: "module" for .js and .mjs files; "commonjs" for .cjs files)
17
+ * - globals - An object specifying additional objects that should be added to the global scope during linting.
18
+ * - parser - An object containing a parse() method or a parseForESLint() method. (default: espree)
19
+ * - parserOptions - An object specifying additional options that are passed directly to the parse() or parseForESLint() method on the parser. The available options are parser-dependent.
20
+ * linterOptions - An object containing settings related to the linting process.
21
+ * - noInlineConfig - A Boolean value indicating if inline configuration is allowed.
22
+ * - reportUnusedDisableDirectives - A severity string indicating if and how unused disable and enable directives should be tracked and reported. For legacy compatibility, true is equivalent to "warn" and false is equivalent to "off". (default: "warn").
23
+ * processor - Either an object containing preprocess() and postprocess() methods or a string indicating the name of a processor inside of a plugin (i.e., "pluginName/processorName").
24
+ * plugins - An object containing a name-value mapping of plugin names to plugin objects. When files is specified, these plugins are only available to the matching files.
25
+ * rules - An object containing the configured rules. When files or ignores are specified, these rule configurations are only available to the matching files.
26
+ * settings - An object containing name-value pairs of information that should be available to all rules.
27
+ */
28
+
29
+ export default function merge (configuration) {
30
+ return {
31
+ ...standard,
32
+ ...configuration,
33
+ languageOptions: mergeLanguageOptions(standard, configuration),
34
+ linterOptions: mergeLinterOptions(standard, configuration),
35
+ rules: mergeRules(standard, configuration),
36
+ settings: mergeSettings(standard, configuration)
37
+ }
38
+ }
@@ -0,0 +1,38 @@
1
+ import stylistic from '#eslint-config-standard/config/stylistic'
2
+
3
+ import {
4
+ mergeLanguageOptions,
5
+ mergeLinterOptions,
6
+ mergeRules,
7
+ mergeSettings
8
+ } from '#eslint-config-standard/common/merge'
9
+
10
+ /**
11
+ * name - A name for the configuration object. This is used in error messages and config inspector to help identify which configuration object is being used. (Naming Convention)
12
+ * files - An array of glob patterns indicating the files that the configuration object should apply to. If not specified, the configuration object applies to all files matched by any other configuration object.
13
+ * ignores - An array of glob patterns indicating the files that the configuration object should not apply to. If not specified, the configuration object applies to all files matched by files. If ignores is used without any other keys in the configuration object, then the patterns act as global ignores.
14
+ * languageOptions - An object containing settings related to how JavaScript is configured for linting.
15
+ * - ecmaVersion - The version of ECMAScript to support. May be any year (i.e., 2022) or version (i.e., 5). Set to "latest" for the most recent supported version. (default: "latest")
16
+ * - sourceType - The type of JavaScript source code. Possible values are "script" for traditional script files, "module" for ECMAScript modules (ESM), and "commonjs" for CommonJS files. (default: "module" for .js and .mjs files; "commonjs" for .cjs files)
17
+ * - globals - An object specifying additional objects that should be added to the global scope during linting.
18
+ * - parser - An object containing a parse() method or a parseForESLint() method. (default: espree)
19
+ * - parserOptions - An object specifying additional options that are passed directly to the parse() or parseForESLint() method on the parser. The available options are parser-dependent.
20
+ * linterOptions - An object containing settings related to the linting process.
21
+ * - noInlineConfig - A Boolean value indicating if inline configuration is allowed.
22
+ * - reportUnusedDisableDirectives - A severity string indicating if and how unused disable and enable directives should be tracked and reported. For legacy compatibility, true is equivalent to "warn" and false is equivalent to "off". (default: "warn").
23
+ * processor - Either an object containing preprocess() and postprocess() methods or a string indicating the name of a processor inside of a plugin (i.e., "pluginName/processorName").
24
+ * plugins - An object containing a name-value mapping of plugin names to plugin objects. When files is specified, these plugins are only available to the matching files.
25
+ * rules - An object containing the configured rules. When files or ignores are specified, these rule configurations are only available to the matching files.
26
+ * settings - An object containing name-value pairs of information that should be available to all rules.
27
+ */
28
+
29
+ export default function merge (configuration) {
30
+ return {
31
+ ...stylistic,
32
+ ...configuration,
33
+ languageOptions: mergeLanguageOptions(stylistic, configuration),
34
+ linterOptions: mergeLinterOptions(stylistic, configuration),
35
+ rules: mergeRules(stylistic, configuration),
36
+ settings: mergeSettings(stylistic, configuration)
37
+ }
38
+ }
package/merge.mjs CHANGED
@@ -1,5 +1,12 @@
1
1
  import standard from '#eslint-config-standard'
2
2
 
3
+ import {
4
+ mergeLanguageOptions,
5
+ mergeLinterOptions,
6
+ mergeRules,
7
+ mergeSettings
8
+ } from '#eslint-config-standard/common/merge'
9
+
3
10
  /**
4
11
  * name - A name for the configuration object. This is used in error messages and config inspector to help identify which configuration object is being used. (Naming Convention)
5
12
  * files - An array of glob patterns indicating the files that the configuration object should apply to. If not specified, the configuration object applies to all files matched by any other configuration object.
@@ -19,137 +26,13 @@ import standard from '#eslint-config-standard'
19
26
  * settings - An object containing name-value pairs of information that should be available to all rules.
20
27
  */
21
28
 
22
- function isString (v) {
23
- return typeof v === 'string'
24
- }
25
-
26
- function isObject (v) {
27
- return (
28
- (v || false).constructor === Object &&
29
- !Array.isArray(v)
30
- )
31
- }
32
-
33
- export function hasPlugins ({ plugins = {} }) {
34
- return !!Object.keys(plugins).length
35
- }
36
-
37
- export function getPlugins ({ plugins = {} }) {
38
- return plugins
39
- }
40
-
41
- export function getLanguageOptions ({ languageOptions = {} }) {
42
- return languageOptions
43
- }
44
-
45
- export function getLinterOptions ({ linterOptions = {} }) {
46
- return linterOptions
47
- }
48
-
49
- export function getProcessor ({ processor = {} }) {
50
- return processor
51
- }
52
-
53
- export function getRules ({ rules = {} }) {
54
- return rules
55
- }
56
-
57
- export function getSettings ({ settings = {} }) {
58
- return settings
59
- }
60
-
61
- export function mergeLanguageOptions (alpha = {}, omega = {}) {
62
- return (
63
- Object.assign(
64
- structuredClone(getLanguageOptions(alpha)),
65
- getLanguageOptions(omega)
66
- )
67
- )
68
- }
69
-
70
- export function mergeLinterOptions (alpha = {}, omega = {}) {
71
- return (
72
- Object.assign(
73
- structuredClone(getLinterOptions(alpha)),
74
- getLinterOptions(omega)
75
- )
76
- )
77
- }
78
-
79
- export function mergeProcessor (alpha = {}, omega = {}) {
80
- if (hasValidProcessor(omega)) {
81
- const processor = getProcessor(omega)
82
-
83
- if (typeof processor === 'string') return processor
84
- return { ...processor }
85
- }
86
-
87
- if (hasValidProcessor(alpha)) {
88
- const processor = getProcessor(alpha)
89
-
90
- if (typeof processor === 'string') return processor
91
- return { ...processor }
92
- }
93
-
94
- return {}
95
- }
96
-
97
- export function mergeRules (alpha = {}, omega = {}) {
98
- return (
99
- Object.assign(
100
- structuredClone(getRules(alpha)),
101
- getRules(omega)
102
- )
103
- )
104
- }
105
-
106
- export function mergeSettings (alpha = {}, omega = {}) {
107
- return (
108
- Object.assign(
109
- structuredClone(getSettings(alpha)),
110
- getSettings(omega)
111
- )
112
- )
113
- }
114
-
115
- function hasValidProcessor (configuration) {
116
- const processor = getProcessor(configuration)
117
-
118
- if (isString(processor)) {
119
- if (hasPlugins(configuration)) {
120
- return (
121
- Reflect.has(getPlugins(configuration), processor)
122
- )
123
- }
124
- }
125
-
126
- if (isObject(processor)) {
127
- if (
128
- Reflect.has(processor, 'preprocess') &&
129
- Reflect.has(processor, 'postprocess')
130
- ) {
131
- return (
132
- Reflect.get(processor, 'preprocess') instanceof Function &&
133
- Reflect.get(processor, 'postprocess') instanceof Function
134
- )
135
- }
136
- }
137
-
138
- return false
139
- }
140
-
141
- export function getMergeWith (omega) {
29
+ function toMergeWith (omega) {
142
30
  return function mergeWith (alpha) {
143
31
  return {
144
32
  ...alpha,
145
33
  ...omega,
146
34
  languageOptions: mergeLanguageOptions(alpha, omega),
147
35
  linterOptions: mergeLinterOptions(alpha, omega),
148
- ...(
149
- hasValidProcessor(alpha) || hasValidProcessor(omega)
150
- ? { processor: mergeProcessor(alpha, omega) }
151
- : {}
152
- ),
153
36
  rules: mergeRules(alpha, omega),
154
37
  settings: mergeSettings(alpha, omega)
155
38
  }
@@ -159,6 +42,6 @@ export function getMergeWith (omega) {
159
42
  export default function merge (omega) {
160
43
  return (
161
44
  standard
162
- .map(getMergeWith(omega))
45
+ .map(toMergeWith(omega))
163
46
  )
164
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequencemedia/eslint-config-standard",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Standard configuration for ESLint 9",
5
5
  "main": "./index.mjs",
6
6
  "type": "module",
@@ -69,11 +69,18 @@
69
69
  "eslint": ">=9"
70
70
  },
71
71
  "imports": {
72
+ "#eslint-config-standard/config/*": "./config/*.mjs",
73
+ "#eslint-config-standard/common/merge/*": "./common/merge/*.mjs",
74
+ "#eslint-config-standard/common/merge": "./common/merge.mjs",
75
+ "#eslint-config-standard/common": "./common/index.mjs",
76
+ "#eslint-config-standard/merge/*": "./merge/*.mjs",
77
+ "#eslint-config-standard/merge": "./merge.mjs",
72
78
  "#eslint-config-standard": "./index.mjs"
73
79
  },
74
80
  "exports": {
75
81
  ".": "./index.mjs",
76
82
  "./config/*": "./config/*.mjs",
83
+ "./merge/*": "./merge/*.mjs",
77
84
  "./merge": "./merge.mjs"
78
85
  }
79
86
  }
@@ -0,0 +1,34 @@
1
+ import {
2
+ expect
3
+ } from 'chai'
4
+
5
+ import {
6
+ isString,
7
+ isObject
8
+ } from '#eslint-config-standard/common'
9
+
10
+ describe('#eslint-config-standard/common', () => {
11
+ describe('`isString`', () => it('is a function', () => expect(isString).to.be.a('function')))
12
+
13
+ describe('`isObject`', () => it('is a function', () => expect(isObject).to.be.a('function')))
14
+
15
+ describe('`isString()`', () => {
16
+ describe('argument is a string', () => it('returns true', () => expect(isString('')).to.true))
17
+ describe('argument is a number', () => it('returns false', () => expect(isString(1)).to.be.false))
18
+ describe('argument is null', () => it('returns false', () => expect(isString(null)).to.be.false))
19
+ describe('argument is undefined', () => it('returns false', () => expect(isString()).to.be.false))
20
+ describe('argument is a boolean', () => it('returns false', () => expect(isString(true)).to.be.false))
21
+ describe('argument is an object', () => it('returns false', () => expect(isString({})).to.be.false))
22
+ describe('argument is an array', () => it('returns false', () => expect(isString([])).to.be.false))
23
+ })
24
+
25
+ describe('`isObject()`', () => {
26
+ describe('argument is a string', () => it('returns false', () => expect(isObject('')).to.false))
27
+ describe('argument is a number', () => it('returns false', () => expect(isObject(1)).to.be.false))
28
+ describe('argument is null', () => it('returns false', () => expect(isObject(null)).to.be.false))
29
+ describe('argument is undefined', () => it('returns false', () => expect(isObject()).to.be.false))
30
+ describe('argument is a boolean', () => it('returns false', () => expect(isObject(true)).to.be.false))
31
+ describe('argument is an object', () => it('returns true', () => expect(isObject({})).to.be.true))
32
+ describe('argument is an array', () => it('returns false', () => expect(isObject([])).to.be.false))
33
+ })
34
+ })
@@ -0,0 +1,109 @@
1
+ import {
2
+ expect
3
+ } from 'chai'
4
+
5
+ import {
6
+ getLanguageOptions,
7
+ getLinterOptions,
8
+ getRules,
9
+ getSettings,
10
+ mergeLanguageOptions,
11
+ mergeLinterOptions,
12
+ mergeRules,
13
+ mergeSettings
14
+ } from '#eslint-config-standard/common/merge'
15
+
16
+ describe('#eslint-config-standard/common/merge', () => {
17
+ const MOCK_LANGUAGE_OPTIONS = {}
18
+ const MOCK_LINTER_OPTIONS = {}
19
+ const MOCK_RULES = {}
20
+ const MOCK_SETTINGS = {}
21
+
22
+ describe('`getLanguageOptions`', () => {
23
+ it('is a function', () => expect(getLanguageOptions).to.be.a('function'))
24
+ })
25
+
26
+ describe('`getLinterOptions`', () => {
27
+ it('is a function', () => expect(getLinterOptions).to.be.a('function'))
28
+ })
29
+
30
+ describe('`getRules`', () => {
31
+ it('is a function', () => expect(getRules).to.be.a('function'))
32
+ })
33
+
34
+ describe('`getSettings`', () => {
35
+ it('is a function', () => expect(getSettings).to.be.a('function'))
36
+ })
37
+
38
+ describe('`mergeLanguageOptions`', () => {
39
+ it('is a function', () => expect(mergeLanguageOptions).to.be.a('function'))
40
+ })
41
+
42
+ describe('`mergeLinterOptions`', () => {
43
+ it('is a function', () => expect(mergeLinterOptions).to.be.a('function'))
44
+ })
45
+
46
+ describe('`mergeRules`', () => {
47
+ it('is a function', () => expect(mergeRules).to.be.a('function'))
48
+ })
49
+
50
+ describe('`mergeSettings`', () => {
51
+ it('is a function', () => expect(mergeSettings).to.be.a('function'))
52
+ })
53
+
54
+ describe('`getLanguageOptions()`', () => {
55
+ it('returns an object', () => (
56
+ expect(getLanguageOptions({ languageOptions: MOCK_LANGUAGE_OPTIONS }))
57
+ .to.equal(MOCK_LANGUAGE_OPTIONS)
58
+ ))
59
+ })
60
+
61
+ describe('`getLinterOptions()`', () => {
62
+ it('returns an object', () => (
63
+ expect(getLinterOptions({ linterOptions: MOCK_LINTER_OPTIONS }))
64
+ .to.equal(MOCK_LINTER_OPTIONS)
65
+ ))
66
+ })
67
+
68
+ describe('`getRules()`', () => {
69
+ it('returns an object', () => (
70
+ expect(getRules({ rules: MOCK_RULES }))
71
+ .to.equal(MOCK_RULES)
72
+ ))
73
+ })
74
+
75
+ describe('`getSettings()`', () => {
76
+ it('returns an object', () => (
77
+ expect(getSettings({ settings: MOCK_SETTINGS }))
78
+ .to.equal(MOCK_SETTINGS)
79
+ ))
80
+ })
81
+
82
+ describe('`mergeLanguageOptions()`', () => {
83
+ it('returns an object', () => (
84
+ expect(mergeLanguageOptions({ languageOptions: { mockOption: 'alpha' } }, { languageOptions: { mockOption: 'omega' } }))
85
+ .to.eql({ mockOption: 'omega' })
86
+ ))
87
+ })
88
+
89
+ describe('`mergeLinterOptions()`', () => {
90
+ it('returns an object', () => (
91
+ expect(mergeLinterOptions({ linterOptions: { mockOption: 'alpha' } }, { linterOptions: { mockOption: 'omega' } }))
92
+ .to.eql({ mockOption: 'omega' })
93
+ ))
94
+ })
95
+
96
+ describe('`mergeRules()`', () => {
97
+ it('returns an object', () => (
98
+ expect(mergeRules({ rules: { mockOption: 'alpha' } }, { rules: { mockOption: 'omega' } }))
99
+ .to.eql({ mockOption: 'omega' })
100
+ ))
101
+ })
102
+
103
+ describe('`mergeSettings()`', () => {
104
+ it('returns an object', () => (
105
+ expect(mergeSettings({ settings: { mockOption: 'alpha' } }, { settings: { mockOption: 'omega' } }))
106
+ .to.eql({ mockOption: 'omega' })
107
+ ))
108
+ })
109
+ })
@@ -0,0 +1,59 @@
1
+ import {
2
+ expect
3
+ } from 'chai'
4
+
5
+ import STANDARD from '#eslint-config-standard/config/standard'
6
+
7
+ import merge from '#eslint-config-standard/merge/standard'
8
+
9
+ describe('#eslint-config-standard/merge/standard', () => {
10
+ describe('`merge`', () => it('is a function', () => expect(merge).to.be.a('function')))
11
+
12
+ describe('`merge()`', () => {
13
+ describe('Always', () => it('returns an object', () => expect(merge()).to.be.an('object')))
14
+
15
+ describe('Merges', () => {
16
+ it('returns an object', () => {
17
+ const MOCK_FILES = [
18
+ 'MOCK FILES'
19
+ ]
20
+ const MOCK_IGNORES = [
21
+ 'MOCK IGNORES'
22
+ ]
23
+ const MOCK_LANGUAGE_OPTIONS = { mockOption: 'MOCK LANGUAGE OPTIONS' }
24
+ const MOCK_LINTER_OPTIONS = { mockOption: 'MOCK LINTER OPTIONS' }
25
+ const MOCK_RULES = { mockOption: 'MOCK RULES' }
26
+ const MOCK_SETTINGS = { mockOption: 'MOCK SETTINGS' }
27
+
28
+ const {
29
+ rules: STANDARD_RULES
30
+ } = STANDARD
31
+
32
+ return (
33
+ expect(
34
+ merge({
35
+ files: MOCK_FILES,
36
+ ignores: MOCK_IGNORES,
37
+ languageOptions: MOCK_LANGUAGE_OPTIONS,
38
+ linterOptions: MOCK_LINTER_OPTIONS,
39
+ rules: MOCK_RULES,
40
+ settings: MOCK_SETTINGS
41
+ })
42
+ )
43
+ .to.eql({
44
+ ...STANDARD,
45
+ files: MOCK_FILES,
46
+ ignores: MOCK_IGNORES,
47
+ languageOptions: MOCK_LANGUAGE_OPTIONS,
48
+ linterOptions: MOCK_LINTER_OPTIONS,
49
+ rules: {
50
+ ...STANDARD_RULES,
51
+ ...MOCK_RULES
52
+ },
53
+ settings: MOCK_SETTINGS
54
+ })
55
+ )
56
+ })
57
+ })
58
+ })
59
+ })
@@ -0,0 +1,59 @@
1
+ import {
2
+ expect
3
+ } from 'chai'
4
+
5
+ import STYLISTIC from '#eslint-config-standard/config/stylistic'
6
+
7
+ import merge from '#eslint-config-standard/merge/stylistic'
8
+
9
+ describe('#eslint-config-standard/merge/stylistic', () => {
10
+ describe('`merge`', () => it('is a function', () => expect(merge).to.be.a('function')))
11
+
12
+ describe('`merge()`', () => {
13
+ describe('Always', () => it('returns an object', () => expect(merge()).to.be.an('object')))
14
+
15
+ describe('Merges', () => {
16
+ it('returns an object', () => {
17
+ const MOCK_FILES = [
18
+ 'MOCK FILES'
19
+ ]
20
+ const MOCK_IGNORES = [
21
+ 'MOCK IGNORES'
22
+ ]
23
+ const MOCK_LANGUAGE_OPTIONS = { mockOption: 'MOCK LANGUAGE OPTIONS' }
24
+ const MOCK_LINTER_OPTIONS = { mockOption: 'MOCK LINTER OPTIONS' }
25
+ const MOCK_RULES = { mockOption: 'MOCK RULES' }
26
+ const MOCK_SETTINGS = { mockOption: 'MOCK SETTINGS' }
27
+
28
+ const {
29
+ rules: STYLISTIC_RULES
30
+ } = STYLISTIC
31
+
32
+ return (
33
+ expect(
34
+ merge({
35
+ files: MOCK_FILES,
36
+ ignores: MOCK_IGNORES,
37
+ languageOptions: MOCK_LANGUAGE_OPTIONS,
38
+ linterOptions: MOCK_LINTER_OPTIONS,
39
+ rules: MOCK_RULES,
40
+ settings: MOCK_SETTINGS
41
+ })
42
+ )
43
+ .to.eql({
44
+ ...STYLISTIC,
45
+ files: MOCK_FILES,
46
+ ignores: MOCK_IGNORES,
47
+ languageOptions: MOCK_LANGUAGE_OPTIONS,
48
+ linterOptions: MOCK_LINTER_OPTIONS,
49
+ rules: {
50
+ ...STYLISTIC_RULES,
51
+ ...MOCK_RULES
52
+ },
53
+ settings: MOCK_SETTINGS
54
+ })
55
+ )
56
+ })
57
+ })
58
+ })
59
+ })
@@ -2,168 +2,88 @@ import {
2
2
  expect
3
3
  } from 'chai'
4
4
 
5
- import {
6
- getLanguageOptions,
7
- getLinterOptions,
8
- getProcessor,
9
- getRules,
10
- getSettings,
11
- mergeLanguageOptions,
12
- mergeLinterOptions,
13
- mergeProcessor,
14
- mergeRules,
15
- mergeSettings
16
- } from '@sequencemedia/eslint-config-standard/merge'
17
-
18
- describe('@sequencemedia/eslint-config-standard/merge', () => {
19
- const MOCK_LANGUAGE_OPTIONS = {}
20
- const MOCK_LINTER_OPTIONS = {}
21
- const MOCK_PROCESSOR = {}
22
- const MOCK_RULES = {}
23
- const MOCK_SETTINGS = {}
24
-
25
- describe('`getLanguageOptions`', () => {
26
- it('is a function', () => expect(getLanguageOptions).to.be.a('function'))
27
- })
28
-
29
- describe('`getLinterOptions`', () => {
30
- it('is a function', () => expect(getLinterOptions).to.be.a('function'))
31
- })
32
-
33
- describe('`getProcessor`', () => {
34
- it('is a function', () => expect(getProcessor).to.be.a('function'))
35
- })
36
-
37
- describe('`getRules`', () => {
38
- it('is a function', () => expect(getRules).to.be.a('function'))
39
- })
40
-
41
- describe('`getSettings`', () => {
42
- it('is a function', () => expect(getSettings).to.be.a('function'))
43
- })
44
-
45
- describe('`mergeLanguageOptions`', () => {
46
- it('is a function', () => expect(mergeLanguageOptions).to.be.a('function'))
47
- })
48
-
49
- describe('`mergeLinterOptions`', () => {
50
- it('is a function', () => expect(mergeLinterOptions).to.be.a('function'))
51
- })
52
-
53
- describe('`mergeProcessor`', () => {
54
- it('is a function', () => expect(mergeProcessor).to.be.a('function'))
55
- })
56
-
57
- describe('`mergeRules`', () => {
58
- it('is a function', () => expect(mergeRules).to.be.a('function'))
59
- })
60
-
61
- describe('`mergeSettings`', () => {
62
- it('is a function', () => expect(mergeSettings).to.be.a('function'))
63
- })
64
-
65
- describe('`getLanguageOptions()`', () => {
66
- it('returns an object', () => (
67
- expect(getLanguageOptions({ languageOptions: MOCK_LANGUAGE_OPTIONS }))
68
- .to.equal(MOCK_LANGUAGE_OPTIONS)
69
- ))
70
- })
71
-
72
- describe('`getLinterOptions()`', () => {
73
- it('returns an object', () => (
74
- expect(getLinterOptions({ linterOptions: MOCK_LINTER_OPTIONS }))
75
- .to.equal(MOCK_LINTER_OPTIONS)
76
- ))
77
- })
78
-
79
- describe('`getProcessor()`', () => {
80
- it('returns an object', () => (
81
- expect(getProcessor({ processor: MOCK_PROCESSOR }))
82
- .to.equal(MOCK_PROCESSOR)
83
- ))
84
- })
85
-
86
- describe('`getRules()`', () => {
87
- it('returns an object', () => (
88
- expect(getRules({ rules: MOCK_RULES }))
89
- .to.equal(MOCK_RULES)
90
- ))
91
- })
92
-
93
- describe('`getSettings()`', () => {
94
- it('returns an object', () => (
95
- expect(getSettings({ settings: MOCK_SETTINGS }))
96
- .to.equal(MOCK_SETTINGS)
97
- ))
98
- })
99
-
100
- describe('`mergeLanguageOptions()`', () => {
101
- it('returns an object', () => (
102
- expect(mergeLanguageOptions({ languageOptions: { mockOption: 'alpha' } }, { languageOptions: { mockOption: 'omega' } }))
103
- .to.eql({ mockOption: 'omega' })
104
- ))
105
- })
106
-
107
- describe('`mergeLinterOptions()`', () => {
108
- it('returns an object', () => (
109
- expect(mergeLinterOptions({ linterOptions: { mockOption: 'alpha' } }, { linterOptions: { mockOption: 'omega' } }))
110
- .to.eql({ mockOption: 'omega' })
111
- ))
112
- })
113
-
114
- describe('`mergeProcessor()`', () => {
115
- describe('an object with `preprocess` and `postprocess` methods', () => {
116
- it('returns an object', () => {
117
- const ALPHA = {
118
- preprocess () { },
119
- postprocess () { }
120
- }
121
-
122
- const OMEGA = {
123
- preprocess () { },
124
- postprocess () { }
125
- }
126
-
127
- return (
128
- expect(mergeProcessor({ processor: ALPHA }, { processor: OMEGA }))
129
- .to.eql(OMEGA)
130
- )
131
- })
132
- })
133
-
134
- describe('a string for a plugin', () => {
135
- it('returns a string', () => {
136
- const ALPHA = {
137
- preprocess () { },
138
- postprocess () { }
139
- }
140
-
141
- const OMEGA = 'mock plugin'
5
+ import STANDARD from '#eslint-config-standard/config/standard'
6
+ import STYLISTIC from '#eslint-config-standard/config/stylistic'
7
+
8
+ import merge from '#eslint-config-standard/merge'
9
+
10
+ describe('#eslint-config-standard/merge', () => {
11
+ describe('`merge`', () => it('is a function', () => expect(merge).to.be.a('function')))
12
+
13
+ describe('`merge()`', () => {
14
+ describe('Always', () => it('returns an array', () => expect(merge()).to.be.an('array')))
15
+
16
+ describe('Merges', () => {
17
+ it('returns an array', () => {
18
+ const MOCK_FILES = [
19
+ 'MOCK FILES'
20
+ ]
21
+ const MOCK_IGNORES = [
22
+ 'MOCK IGNORES'
23
+ ]
24
+ const MOCK_LANGUAGE_OPTIONS = { mockOption: 'MOCK LANGUAGE OPTIONS' }
25
+ const MOCK_LINTER_OPTIONS = { mockOption: 'MOCK LINTER OPTIONS' }
26
+ const MOCK_RULES = { mockOption: 'MOCK RULES' }
27
+ const MOCK_SETTINGS = { mockOption: 'MOCK SETTINGS' }
28
+
29
+ const {
30
+ rules: STANDARD_RULES
31
+ } = STANDARD
32
+
33
+ const {
34
+ rules: STYLISTIC_RULES
35
+ } = STYLISTIC
142
36
 
143
37
  return (
144
- expect(mergeProcessor({ processor: ALPHA }, {
145
- plugins: {
146
- [OMEGA]: {}
147
- },
148
- processor: OMEGA
149
- }))
150
- .to.eql(OMEGA)
38
+ expect(
39
+ merge({
40
+ files: MOCK_FILES,
41
+ ignores: MOCK_IGNORES,
42
+ languageOptions: MOCK_LANGUAGE_OPTIONS,
43
+ linterOptions: MOCK_LINTER_OPTIONS,
44
+ rules: MOCK_RULES,
45
+ settings: MOCK_SETTINGS
46
+ })
47
+ )
48
+ .to.eql([
49
+ {
50
+ name: '@sequencemedia/eslint-config-standard',
51
+ files: MOCK_FILES,
52
+ ignores: MOCK_IGNORES,
53
+ languageOptions: {
54
+ ecmaVersion: 'latest',
55
+ ...MOCK_LANGUAGE_OPTIONS
56
+ },
57
+ linterOptions: MOCK_LINTER_OPTIONS,
58
+ rules: MOCK_RULES,
59
+ settings: MOCK_SETTINGS
60
+ },
61
+ {
62
+ ...STANDARD,
63
+ files: MOCK_FILES,
64
+ ignores: MOCK_IGNORES,
65
+ languageOptions: MOCK_LANGUAGE_OPTIONS,
66
+ linterOptions: MOCK_LINTER_OPTIONS,
67
+ rules: {
68
+ ...STANDARD_RULES,
69
+ ...MOCK_RULES
70
+ },
71
+ settings: MOCK_SETTINGS
72
+ },
73
+ {
74
+ ...STYLISTIC,
75
+ files: MOCK_FILES,
76
+ ignores: MOCK_IGNORES,
77
+ languageOptions: MOCK_LANGUAGE_OPTIONS,
78
+ linterOptions: MOCK_LINTER_OPTIONS,
79
+ rules: {
80
+ ...STYLISTIC_RULES,
81
+ ...MOCK_RULES
82
+ },
83
+ settings: MOCK_SETTINGS
84
+ }])
151
85
  )
152
86
  })
153
87
  })
154
88
  })
155
-
156
- describe('`mergeRules()`', () => {
157
- it('returns an object', () => (
158
- expect(mergeRules({ rules: { mockOption: 'alpha' } }, { rules: { mockOption: 'omega' } }))
159
- .to.eql({ mockOption: 'omega' })
160
- ))
161
- })
162
-
163
- describe('`mergeSettings()`', () => {
164
- it('returns an object', () => (
165
- expect(mergeSettings({ settings: { mockOption: 'alpha' } }, { settings: { mockOption: 'omega' } }))
166
- .to.eql({ mockOption: 'omega' })
167
- ))
168
- })
169
89
  })