@sequencemedia/eslint-config-standard 0.1.1 → 0.1.2

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.
package/common/merge.mjs CHANGED
@@ -6,20 +6,24 @@ function getLanguageOptionsParser ({ languageOptions: { parser = null } = {} })
6
6
  return parser
7
7
  }
8
8
 
9
- function filterLanguageOptionsEntriesbyKey ([key]) {
9
+ function removeParserByEntriesKey ([key]) {
10
10
  return key !== 'parser'
11
11
  }
12
12
 
13
- export function getLanguageOptions ({ languageOptions = {} }) {
13
+ export function getLanguageOptionsWithoutParser ({ languageOptions = {} }) {
14
14
  const entries = Object.entries(languageOptions)
15
15
 
16
16
  return (
17
17
  Object.fromEntries(
18
- entries.filter(filterLanguageOptionsEntriesbyKey)
18
+ entries.filter(removeParserByEntriesKey)
19
19
  )
20
20
  )
21
21
  }
22
22
 
23
+ export function getLanguageOptions ({ languageOptions = {} }) {
24
+ return languageOptions
25
+ }
26
+
23
27
  export function getLinterOptions ({ linterOptions = {} }) {
24
28
  return linterOptions
25
29
  }
@@ -41,8 +45,7 @@ export function mergeLanguageOptions (alpha = {}, omega = {}) {
41
45
  Object
42
46
  .assign(
43
47
  hasLanguageOptionsParser(alpha) ? { parser: getLanguageOptionsParser(alpha) } : {},
44
- structuredClone(getLanguageOptions(alpha)),
45
- hasLanguageOptionsParser(omega) ? { parser: getLanguageOptionsParser(omega) } : {},
48
+ structuredClone(getLanguageOptionsWithoutParser(alpha)),
46
49
  getLanguageOptions(omega)
47
50
  )
48
51
  )
@@ -1,38 +1,12 @@
1
- import standard from '#eslint-config-standard/config/standard'
1
+ import merge from '@sequencemedia/eslint-merge'
2
2
 
3
- import {
4
- mergeLanguageOptions,
5
- mergeLinterOptions,
6
- mergeRules,
7
- mergeSettings
8
- } from '#eslint-config-standard/common/merge'
3
+ import CONFIG from '#eslint-config-standard/config/standard'
9
4
 
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
- }
5
+ export default function mergeConfig (config) {
6
+ return (
7
+ merge(
8
+ CONFIG,
9
+ config
10
+ )
11
+ )
38
12
  }
@@ -1,38 +1,12 @@
1
- import stylistic from '#eslint-config-standard/config/stylistic'
1
+ import merge from '@sequencemedia/eslint-merge'
2
2
 
3
- import {
4
- mergeLanguageOptions,
5
- mergeLinterOptions,
6
- mergeRules,
7
- mergeSettings
8
- } from '#eslint-config-standard/common/merge'
3
+ import CONFIG from '#eslint-config-standard/config/stylistic'
9
4
 
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
- }
5
+ export default function mergeConfig (config) {
6
+ return (
7
+ merge(
8
+ CONFIG,
9
+ config
10
+ )
11
+ )
38
12
  }
package/merge.mjs CHANGED
@@ -1,47 +1,10 @@
1
- import standard from '#eslint-config-standard'
1
+ import mergeWith from '@sequencemedia/eslint-merge/merge-with'
2
2
 
3
- import {
4
- mergeLanguageOptions,
5
- mergeLinterOptions,
6
- mergeRules,
7
- mergeSettings
8
- } from '#eslint-config-standard/common/merge'
3
+ import eslintConfig from './index.mjs'
9
4
 
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
- function toMergeWith (omega) {
30
- return function mergeWith (alpha) {
31
- return {
32
- ...alpha,
33
- ...omega,
34
- languageOptions: mergeLanguageOptions(alpha, omega),
35
- linterOptions: mergeLinterOptions(alpha, omega),
36
- rules: mergeRules(alpha, omega),
37
- settings: mergeSettings(alpha, omega)
38
- }
39
- }
40
- }
41
-
42
- export default function merge (omega) {
5
+ export default function mergeESLintConfigWith (config) {
43
6
  return (
44
- standard
45
- .map(toMergeWith(omega))
7
+ eslintConfig
8
+ .map(mergeWith(config))
46
9
  )
47
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequencemedia/eslint-config-standard",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Standard configuration for ESLint 9",
5
5
  "keywords": [
6
6
  "JavaScript Standard Style",
@@ -51,6 +51,7 @@
51
51
  "test": "mocha test --recursive --verbose --color"
52
52
  },
53
53
  "dependencies": {
54
+ "@sequencemedia/eslint-merge": "^0.0.0",
54
55
  "@stylistic/eslint-plugin": "^2.11.0",
55
56
  "eslint-plugin-n": "^17.14.0",
56
57
  "globals": "^15.13.0"
@@ -67,14 +68,13 @@
67
68
  "imports": {
68
69
  "#eslint-config-standard": "./index.mjs",
69
70
  "#eslint-config-standard/common": "./common/index.mjs",
70
- "#eslint-config-standard/common/merge": "./common/merge.mjs",
71
- "#eslint-config-standard/common/merge/*": "./common/merge/*.mjs",
72
71
  "#eslint-config-standard/config/*": "./config/*.mjs",
73
72
  "#eslint-config-standard/merge": "./merge.mjs",
74
73
  "#eslint-config-standard/merge/*": "./merge/*.mjs"
75
74
  },
76
75
  "exports": {
77
76
  ".": "./index.mjs",
77
+ "./common": "./common/index.mjs",
78
78
  "./config/*": "./config/*.mjs",
79
79
  "./merge": "./merge.mjs",
80
80
  "./merge/*": "./merge/*.mjs"
@@ -5,9 +5,9 @@ import {
5
5
  import {
6
6
  isString,
7
7
  isObject
8
- } from '#eslint-config-standard/common'
8
+ } from '@sequencemedia/eslint-config-standard/common'
9
9
 
10
- describe('#eslint-config-standard/common', () => {
10
+ describe('@sequencemedia/eslint-config-standard/common', () => {
11
11
  describe('`isString`', () => it('is a function', () => expect(isString).to.be.a('function')))
12
12
 
13
13
  describe('`isObject`', () => it('is a function', () => expect(isObject).to.be.a('function')))
@@ -2,11 +2,11 @@ import {
2
2
  expect
3
3
  } from 'chai'
4
4
 
5
- import STANDARD from '#eslint-config-standard/config/standard'
5
+ import STANDARD from '@sequencemedia/eslint-config-standard/config/standard'
6
6
 
7
- import merge from '#eslint-config-standard/merge/standard'
7
+ import merge from '@sequencemedia/eslint-config-standard/merge/standard'
8
8
 
9
- describe('#eslint-config-standard/merge/standard', () => {
9
+ describe('@sequencemedia/eslint-config-standard/merge/standard', () => {
10
10
  describe('`merge`', () => it('is a function', () => expect(merge).to.be.a('function')))
11
11
 
12
12
  describe('`merge()`', () => {
@@ -2,11 +2,11 @@ import {
2
2
  expect
3
3
  } from 'chai'
4
4
 
5
- import STYLISTIC from '#eslint-config-standard/config/stylistic'
5
+ import STYLISTIC from '@sequencemedia/eslint-config-standard/config/stylistic'
6
6
 
7
- import merge from '#eslint-config-standard/merge/stylistic'
7
+ import merge from '@sequencemedia/eslint-config-standard/merge/stylistic'
8
8
 
9
- describe('#eslint-config-standard/merge/stylistic', () => {
9
+ describe('@sequencemedia/eslint-config-standard/merge/stylistic', () => {
10
10
  describe('`merge`', () => it('is a function', () => expect(merge).to.be.a('function')))
11
11
 
12
12
  describe('`merge()`', () => {
@@ -2,12 +2,12 @@ import {
2
2
  expect
3
3
  } from 'chai'
4
4
 
5
- import STANDARD from '#eslint-config-standard/config/standard'
6
- import STYLISTIC from '#eslint-config-standard/config/stylistic'
5
+ import STANDARD from '@sequencemedia/eslint-config-standard/config/standard'
6
+ import STYLISTIC from '@sequencemedia/eslint-config-standard/config/stylistic'
7
7
 
8
- import merge from '#eslint-config-standard/merge'
8
+ import merge from '@sequencemedia/eslint-config-standard/merge'
9
9
 
10
- describe('#eslint-config-standard/merge', () => {
10
+ describe('@sequencemedia/eslint-config-standard/merge', () => {
11
11
  describe('`merge`', () => it('is a function', () => expect(merge).to.be.a('function')))
12
12
 
13
13
  describe('`merge()`', () => {
@@ -1,109 +0,0 @@
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
- })