@form8ion/eslint-config-extender 12.0.0-beta.3 → 12.0.0-beta.4
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/README.md +22 -10
- package/example.js +21 -9
- package/lib/index.mjs +12 -11
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/language-handler-prompt.js +4 -3
- package/src/language-handler-prompt.test.js +5 -5
package/README.md
CHANGED
|
@@ -47,13 +47,12 @@ $ npm install @form8ion/eslint-config-extender --save-prod
|
|
|
47
47
|
|
|
48
48
|
```javascript
|
|
49
49
|
import {promptConstants} from '@form8ion/project';
|
|
50
|
+
import {packageManagers} from '@form8ion/javascript-core';
|
|
50
51
|
```
|
|
51
52
|
|
|
52
53
|
```javascript
|
|
53
|
-
const {packageManagers} = await import('@form8ion/javascript-core');
|
|
54
|
-
const {questionNames: projectQuestionNames} = await import('@form8ion/project');
|
|
55
54
|
const javascriptPlugin = await import('@form8ion/javascript');
|
|
56
|
-
const {scaffold, extendEslintConfig} = await import('
|
|
55
|
+
const {scaffold, extendEslintConfig} = await import('@form8ion/eslint-config-extender');
|
|
57
56
|
```
|
|
58
57
|
|
|
59
58
|
#### Execute
|
|
@@ -107,16 +106,29 @@ const {scaffold, extendEslintConfig} = await import('./lib/index.mjs');
|
|
|
107
106
|
}),
|
|
108
107
|
{
|
|
109
108
|
prompt: ({id}) => {
|
|
109
|
+
const {questionNames: projectQuestionNames, ids} = promptConstants;
|
|
110
|
+
const baseDetailsPromptId = ids.BASE_DETAILS;
|
|
111
|
+
|
|
110
112
|
switch (id) {
|
|
111
|
-
case promptConstants.ids.BASE_DETAILS:
|
|
113
|
+
case promptConstants.ids.BASE_DETAILS: {
|
|
114
|
+
const {
|
|
115
|
+
PROJECT_NAME,
|
|
116
|
+
LICENSE,
|
|
117
|
+
VISIBILITY,
|
|
118
|
+
DESCRIPTION,
|
|
119
|
+
COPYRIGHT_HOLDER,
|
|
120
|
+
COPYRIGHT_YEAR
|
|
121
|
+
} = projectQuestionNames[baseDetailsPromptId];
|
|
122
|
+
|
|
112
123
|
return {
|
|
113
|
-
[
|
|
114
|
-
[
|
|
115
|
-
[
|
|
116
|
-
[
|
|
117
|
-
[
|
|
118
|
-
[
|
|
124
|
+
[PROJECT_NAME]: 'eslint-config-foo',
|
|
125
|
+
[DESCRIPTION]: 'a description of the project',
|
|
126
|
+
[VISIBILITY]: 'Public',
|
|
127
|
+
[LICENSE]: 'MIT',
|
|
128
|
+
[COPYRIGHT_HOLDER]: 'John Smith',
|
|
129
|
+
[COPYRIGHT_YEAR]: '2022'
|
|
119
130
|
};
|
|
131
|
+
}
|
|
120
132
|
case promptConstants.ids.GIT_REPOSITORY:
|
|
121
133
|
return {[projectQuestionNames.GIT_REPO]: true};
|
|
122
134
|
case promptConstants.ids.REPOSITORY_HOST:
|
package/example.js
CHANGED
|
@@ -5,6 +5,7 @@ import stubbedFs from 'mock-fs';
|
|
|
5
5
|
import * as td from 'testdouble';
|
|
6
6
|
import any from '@travi/any';
|
|
7
7
|
import {promptConstants} from '@form8ion/project';
|
|
8
|
+
import {packageManagers} from '@form8ion/javascript-core';
|
|
8
9
|
|
|
9
10
|
// remark-usage-ignore-next 13
|
|
10
11
|
const stubbedNodeModules = stubbedFs.load(resolve('node_modules'));
|
|
@@ -21,8 +22,6 @@ td.when(execa('npm run generate:md && npm test', {shell: true})).thenReturn({std
|
|
|
21
22
|
td.when(execa('npm', ['whoami'])).thenResolve({stdout: any.word()});
|
|
22
23
|
td.when(execa('npm', ['--version'])).thenResolve({stdout: any.word()});
|
|
23
24
|
|
|
24
|
-
const {packageManagers} = await import('@form8ion/javascript-core');
|
|
25
|
-
const {questionNames: projectQuestionNames} = await import('@form8ion/project');
|
|
26
25
|
const javascriptPlugin = await import('@form8ion/javascript');
|
|
27
26
|
const {scaffold, extendEslintConfig} = await import('./lib/index.mjs');
|
|
28
27
|
|
|
@@ -77,16 +76,29 @@ stubbedFs({node_modules: stubbedNodeModules});
|
|
|
77
76
|
}),
|
|
78
77
|
{
|
|
79
78
|
prompt: ({id}) => {
|
|
79
|
+
const {questionNames: projectQuestionNames, ids} = promptConstants;
|
|
80
|
+
const baseDetailsPromptId = ids.BASE_DETAILS;
|
|
81
|
+
|
|
80
82
|
switch (id) {
|
|
81
|
-
case promptConstants.ids.BASE_DETAILS:
|
|
83
|
+
case promptConstants.ids.BASE_DETAILS: {
|
|
84
|
+
const {
|
|
85
|
+
PROJECT_NAME,
|
|
86
|
+
LICENSE,
|
|
87
|
+
VISIBILITY,
|
|
88
|
+
DESCRIPTION,
|
|
89
|
+
COPYRIGHT_HOLDER,
|
|
90
|
+
COPYRIGHT_YEAR
|
|
91
|
+
} = projectQuestionNames[baseDetailsPromptId];
|
|
92
|
+
|
|
82
93
|
return {
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[
|
|
94
|
+
[PROJECT_NAME]: 'eslint-config-foo',
|
|
95
|
+
[DESCRIPTION]: 'a description of the project',
|
|
96
|
+
[VISIBILITY]: 'Public',
|
|
97
|
+
[LICENSE]: 'MIT',
|
|
98
|
+
[COPYRIGHT_HOLDER]: 'John Smith',
|
|
99
|
+
[COPYRIGHT_YEAR]: '2022'
|
|
89
100
|
};
|
|
101
|
+
}
|
|
90
102
|
case promptConstants.ids.GIT_REPOSITORY:
|
|
91
103
|
return {[projectQuestionNames.GIT_REPO]: true};
|
|
92
104
|
case promptConstants.ids.REPOSITORY_HOST:
|
package/lib/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { promises } from 'node:fs';
|
|
|
2
2
|
import { fileTypes } from '@form8ion/core';
|
|
3
3
|
import { write } from '@form8ion/config-file';
|
|
4
4
|
import deepmerge from 'deepmerge';
|
|
5
|
-
import { questionNames
|
|
5
|
+
import { questionNames } from '@form8ion/javascript';
|
|
6
6
|
import { dialects } from '@form8ion/javascript-core';
|
|
7
|
-
import { promptConstants,
|
|
7
|
+
import { promptConstants, scaffold } from '@form8ion/project';
|
|
8
8
|
|
|
9
9
|
async function scaffoldEslintConfig({projectRoot, scope, projectName}) {
|
|
10
10
|
const configShortName = projectName.substring('eslint-config-'.length);
|
|
@@ -49,9 +49,10 @@ const JAVASCRIPT_LANGUAGE_CHOICE = 'JavaScript';
|
|
|
49
49
|
function injectLanguageChoiceIntoPrompt(prompt) {
|
|
50
50
|
return promptOptions => {
|
|
51
51
|
const {id} = promptOptions;
|
|
52
|
+
const projectLanguagePromptId = promptConstants.ids.PROJECT_LANGUAGE;
|
|
52
53
|
|
|
53
|
-
if (
|
|
54
|
-
return {[questionNames.PROJECT_LANGUAGE]: JAVASCRIPT_LANGUAGE_CHOICE};
|
|
54
|
+
if (projectLanguagePromptId === id) {
|
|
55
|
+
return {[promptConstants.questionNames[projectLanguagePromptId].PROJECT_LANGUAGE]: JAVASCRIPT_LANGUAGE_CHOICE};
|
|
55
56
|
}
|
|
56
57
|
return prompt(promptOptions);
|
|
57
58
|
};
|
|
@@ -68,13 +69,13 @@ function extendEslintConfig(options, javascriptPluginFactory, dependencies) {
|
|
|
68
69
|
languages: {
|
|
69
70
|
[JAVASCRIPT_LANGUAGE_CHOICE]: javascriptPluginFactory({
|
|
70
71
|
...decisions,
|
|
71
|
-
[questionNames
|
|
72
|
-
[questionNames
|
|
73
|
-
[questionNames
|
|
74
|
-
[questionNames
|
|
75
|
-
[questionNames
|
|
76
|
-
[questionNames
|
|
77
|
-
[questionNames
|
|
72
|
+
[questionNames.PROJECT_TYPE]: 'Package',
|
|
73
|
+
[questionNames.PROJECT_TYPE_CHOICE]: PLUGIN_NAME,
|
|
74
|
+
[questionNames.UNIT_TESTS]: false,
|
|
75
|
+
[questionNames.INTEGRATION_TESTS]: false,
|
|
76
|
+
[questionNames.CONFIGURE_LINTING]: false,
|
|
77
|
+
[questionNames.DIALECT]: dialects.COMMON_JS,
|
|
78
|
+
[questionNames.SHOULD_BE_SCOPED]: true
|
|
78
79
|
})
|
|
79
80
|
}
|
|
80
81
|
}
|
package/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/scaffold.js","../src/constants.js","../src/language-handler-prompt.js","../src/high-level.js"],"sourcesContent":["import {promises as fs} from 'node:fs';\nimport {fileTypes} from '@form8ion/core';\nimport {write} from '@form8ion/config-file';\n\nexport default async function scaffoldEslintConfig({projectRoot, scope, projectName}) {\n const configShortName = projectName.substring('eslint-config-'.length);\n\n await Promise.all([\n write({\n format: fileTypes.YAML,\n path: projectRoot,\n name: 'eslint',\n config: {root: true, extends: [`@${scope}`, '.']}\n }),\n fs.writeFile(\n `${projectRoot}/index.js`,\n `module.exports = {extends: '@form8ion/${configShortName}'};\\n`\n ),\n fs.writeFile(\n `${projectRoot}/example.js`,\n `module.exports = {\n extends: [\n '@${scope}',\n '@${scope}/${configShortName}'\n ]\n};\n`\n )\n ]);\n\n return {\n scripts: {'lint:js': 'eslint .'},\n dependencies: {javascript: {production: [`@form8ion/${projectName}`], development: [`@${scope}/eslint-config`]}},\n nextSteps: [\n {summary: 'Save the extended `@form8ion` eslint-config as an exact version'},\n {summary: 'Document saving this config using the dev flag'},\n {summary: 'Link to the extended `@form8ion` config in the README'}\n ]\n };\n}\n","export const PLUGIN_NAME = 'ESLint Config';\nexport const JAVASCRIPT_LANGUAGE_CHOICE = 'JavaScript';\n","import {promptConstants
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/scaffold.js","../src/constants.js","../src/language-handler-prompt.js","../src/high-level.js"],"sourcesContent":["import {promises as fs} from 'node:fs';\nimport {fileTypes} from '@form8ion/core';\nimport {write} from '@form8ion/config-file';\n\nexport default async function scaffoldEslintConfig({projectRoot, scope, projectName}) {\n const configShortName = projectName.substring('eslint-config-'.length);\n\n await Promise.all([\n write({\n format: fileTypes.YAML,\n path: projectRoot,\n name: 'eslint',\n config: {root: true, extends: [`@${scope}`, '.']}\n }),\n fs.writeFile(\n `${projectRoot}/index.js`,\n `module.exports = {extends: '@form8ion/${configShortName}'};\\n`\n ),\n fs.writeFile(\n `${projectRoot}/example.js`,\n `module.exports = {\n extends: [\n '@${scope}',\n '@${scope}/${configShortName}'\n ]\n};\n`\n )\n ]);\n\n return {\n scripts: {'lint:js': 'eslint .'},\n dependencies: {javascript: {production: [`@form8ion/${projectName}`], development: [`@${scope}/eslint-config`]}},\n nextSteps: [\n {summary: 'Save the extended `@form8ion` eslint-config as an exact version'},\n {summary: 'Document saving this config using the dev flag'},\n {summary: 'Link to the extended `@form8ion` config in the README'}\n ]\n };\n}\n","export const PLUGIN_NAME = 'ESLint Config';\nexport const JAVASCRIPT_LANGUAGE_CHOICE = 'JavaScript';\n","import {promptConstants} from '@form8ion/project';\nimport {JAVASCRIPT_LANGUAGE_CHOICE} from './constants.js';\n\nexport default function injectLanguageChoiceIntoPrompt(prompt) {\n return promptOptions => {\n const {id} = promptOptions;\n const projectLanguagePromptId = promptConstants.ids.PROJECT_LANGUAGE;\n\n if (projectLanguagePromptId === id) {\n return {[promptConstants.questionNames[projectLanguagePromptId].PROJECT_LANGUAGE]: JAVASCRIPT_LANGUAGE_CHOICE};\n }\n return prompt(promptOptions);\n };\n}\n","import deepmerge from 'deepmerge';\nimport {questionNames as jsQuestionNames} from '@form8ion/javascript';\nimport {dialects} from '@form8ion/javascript-core';\nimport {scaffold} from '@form8ion/project';\n\nimport {JAVASCRIPT_LANGUAGE_CHOICE, PLUGIN_NAME} from './constants.js';\nimport injectLanguageChoiceIntoPrompt from './language-handler-prompt.js';\n\nexport default function extendEslintConfig(options, javascriptPluginFactory, dependencies) {\n const {decisions, ...otherOptions} = options;\n\n return scaffold(\n deepmerge(\n otherOptions,\n {\n plugins: {\n languages: {\n [JAVASCRIPT_LANGUAGE_CHOICE]: javascriptPluginFactory({\n ...decisions,\n [jsQuestionNames.PROJECT_TYPE]: 'Package',\n [jsQuestionNames.PROJECT_TYPE_CHOICE]: PLUGIN_NAME,\n [jsQuestionNames.UNIT_TESTS]: false,\n [jsQuestionNames.INTEGRATION_TESTS]: false,\n [jsQuestionNames.CONFIGURE_LINTING]: false,\n [jsQuestionNames.DIALECT]: dialects.COMMON_JS,\n [jsQuestionNames.SHOULD_BE_SCOPED]: true\n })\n }\n }\n }\n ),\n {\n ...dependencies,\n prompt: injectLanguageChoiceIntoPrompt(dependencies.prompt)\n }\n );\n}\n"],"names":["fs","jsQuestionNames"],"mappings":";;;;;;;;AAIe,eAAe,oBAAoB,CAAC,CAAC,WAAW,EAAE,KAAK,EAAE,WAAW,CAAC,EAAE;AACtF,EAAE,MAAM,eAAe,GAAG,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC;;AAExE,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC;AACpB,IAAI,KAAK,CAAC;AACV,MAAM,MAAM,EAAE,SAAS,CAAC,IAAI;AAC5B,MAAM,IAAI,EAAE,WAAW;AACvB,MAAM,IAAI,EAAE,QAAQ;AACpB,MAAM,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;AACtD,KAAK,CAAC;AACN,IAAIA,QAAE,CAAC,SAAS;AAChB,MAAM,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC;AAC/B,MAAM,CAAC,sCAAsC,EAAE,eAAe,CAAC,KAAK;AACpE,KAAK;AACL,IAAIA,QAAE,CAAC,SAAS;AAChB,MAAM,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC;AACjC,MAAM,CAAC;AACP;AACA,MAAM,EAAE,KAAK,CAAC;AACd,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC;AACjC;AACA;AACA;AACA;AACA,GAAG,CAAC;;AAEJ,EAAE,OAAO;AACT,IAAI,OAAO,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;AACpC,IAAI,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC,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A,aAAe,CAAC,UAAU,GAAG,KAAK;AACjD,cAAc,CAACA,aAAe,CAAC,iBAAiB,GAAG,KAAK;AACxD,cAAc,CAACA,aAAe,CAAC,iBAAiB,GAAG,KAAK;AACxD,cAAc,CAACA,aAAe,CAAC,OAAO,GAAG,QAAQ,CAAC,SAAS;AAC3D,cAAc,CAACA,aAAe,CAAC,gBAAgB,GAAG;AAClD,aAAa;AACb;AACA;AACA;AACA,KAAK;AACL,IAAI;AACJ,MAAM,GAAG,YAAY;AACrB,MAAM,MAAM,EAAE,8BAA8B,CAAC,YAAY,CAAC,MAAM;AAChE;AACA,GAAG;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@form8ion/eslint-config-extender",
|
|
3
3
|
"description": "shareable ESLint config scaffolder for extending another config",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "12.0.0-beta.
|
|
5
|
+
"version": "12.0.0-beta.4",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": "^22.21.0 || >=24.12"
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@form8ion/core": "^4.7.1",
|
|
61
61
|
"@form8ion/javascript": "^15.0.0",
|
|
62
62
|
"@form8ion/javascript-core": "^12.0.0",
|
|
63
|
-
"@form8ion/project": "22.0.0-beta.
|
|
63
|
+
"@form8ion/project": "^22.0.0-beta.15",
|
|
64
64
|
"deepmerge": "^4.2.2"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {promptConstants
|
|
1
|
+
import {promptConstants} from '@form8ion/project';
|
|
2
2
|
import {JAVASCRIPT_LANGUAGE_CHOICE} from './constants.js';
|
|
3
3
|
|
|
4
4
|
export default function injectLanguageChoiceIntoPrompt(prompt) {
|
|
5
5
|
return promptOptions => {
|
|
6
6
|
const {id} = promptOptions;
|
|
7
|
+
const projectLanguagePromptId = promptConstants.ids.PROJECT_LANGUAGE;
|
|
7
8
|
|
|
8
|
-
if (
|
|
9
|
-
return {[
|
|
9
|
+
if (projectLanguagePromptId === id) {
|
|
10
|
+
return {[promptConstants.questionNames[projectLanguagePromptId].PROJECT_LANGUAGE]: JAVASCRIPT_LANGUAGE_CHOICE};
|
|
10
11
|
}
|
|
11
12
|
return prompt(promptOptions);
|
|
12
13
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {promptConstants
|
|
1
|
+
import {promptConstants} from '@form8ion/project';
|
|
2
2
|
|
|
3
3
|
import {describe, it, vi, expect} from 'vitest';
|
|
4
4
|
import {when} from 'vitest-when';
|
|
@@ -18,9 +18,9 @@ describe('language choice handler prompt', () => {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it('should define the language choice as JavaScript for the language handler prompt', async () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const projectLanguagePromptId = promptConstants.ids.PROJECT_LANGUAGE;
|
|
22
|
+
|
|
23
|
+
expect(await injectLanguageChoiceIntoPrompt(() => undefined)({...any.simpleObject(), id: projectLanguagePromptId}))
|
|
24
|
+
.toEqual({[promptConstants.questionNames[projectLanguagePromptId].PROJECT_LANGUAGE]: JAVASCRIPT_LANGUAGE_CHOICE});
|
|
25
25
|
});
|
|
26
26
|
});
|