create-airbnb-x-config 2.1.0 → 2.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/README.md +12 -0
- package/dist/constants/index.d.ts +6 -0
- package/dist/constants/index.js +7 -1
- package/dist/helpers/getArgs.d.ts +5 -1
- package/dist/helpers/getArgs.js +12 -0
- package/dist/helpers/getConfigUrl.d.ts +1 -1
- package/dist/helpers/getConfigUrl.js +9 -1
- package/dist/helpers/program.d.ts +1 -1
- package/dist/helpers/program.js +4 -1
- package/dist/index.js +54 -0
- package/dist/lib/templates/configs.d.ts +13 -0
- package/dist/lib/templates/configs.js +205 -0
- package/dist/lib/templates/constants.d.ts +24 -0
- package/dist/lib/templates/constants.js +11 -0
- package/dist/lib/templates/contentFormatter.d.ts +4 -0
- package/dist/lib/templates/contentFormatter.js +12 -0
- package/dist/lib/templates/createDirectories.d.ts +3 -0
- package/dist/lib/templates/createDirectories.js +31 -0
- package/dist/lib/templates/getAllFolders.d.ts +19 -0
- package/dist/lib/templates/getAllFolders.js +29 -0
- package/dist/lib/templates/getContent.d.ts +17 -0
- package/dist/lib/templates/getContent.js +39 -0
- package/dist/lib/templates/getDefaultSubFolders.d.ts +7 -0
- package/dist/lib/templates/getDefaultSubFolders.js +102 -0
- package/dist/lib/templates/getFolders.d.ts +4 -0
- package/dist/lib/templates/getFolders.js +61 -0
- package/dist/lib/templates/index.d.ts +1 -0
- package/dist/lib/templates/index.js +25 -0
- package/dist/lib/templates/writeFiles.d.ts +3 -0
- package/dist/lib/templates/writeFiles.js +41 -0
- package/dist/package.json +3 -2
- package/package.json +3 -2
- package/templates/next/js/strict/import/eslint.config.mjs +52 -0
- package/templates/next/js/strict/import-react/eslint.config.mjs +54 -0
- package/templates/next/js/strict/react/eslint.config.mjs +52 -0
- package/templates/next/prettier/js/strict/import/eslint.config.mjs +74 -0
- package/templates/next/prettier/js/strict/import-react/eslint.config.mjs +76 -0
- package/templates/next/prettier/js/strict/react/eslint.config.mjs +74 -0
- package/templates/next/prettier/ts/strict/import/eslint.config.mjs +85 -0
- package/templates/next/prettier/ts/strict/import-react/eslint.config.mjs +87 -0
- package/templates/next/prettier/ts/strict/import-react-typescript/eslint.config.mjs +89 -0
- package/templates/next/prettier/ts/strict/import-typescript/eslint.config.mjs +87 -0
- package/templates/next/prettier/ts/strict/react/eslint.config.mjs +85 -0
- package/templates/next/prettier/ts/strict/react-typescript/eslint.config.mjs +87 -0
- package/templates/next/prettier/ts/strict/typescript/eslint.config.mjs +85 -0
- package/templates/next/ts/strict/import/eslint.config.mjs +63 -0
- package/templates/next/ts/strict/import-react/eslint.config.mjs +65 -0
- package/templates/next/ts/strict/import-react-typescript/eslint.config.mjs +67 -0
- package/templates/next/ts/strict/import-typescript/eslint.config.mjs +65 -0
- package/templates/next/ts/strict/react/eslint.config.mjs +63 -0
- package/templates/next/ts/strict/react-typescript/eslint.config.mjs +65 -0
- package/templates/next/ts/strict/typescript/eslint.config.mjs +63 -0
- package/templates/node/js/strict/import/eslint.config.mjs +46 -0
- package/templates/node/prettier/js/strict/import/eslint.config.mjs +68 -0
- package/templates/node/prettier/ts/strict/import/eslint.config.mjs +77 -0
- package/templates/node/prettier/ts/strict/import-typescript/eslint.config.mjs +79 -0
- package/templates/node/prettier/ts/strict/typescript/eslint.config.mjs +77 -0
- package/templates/node/ts/strict/import/eslint.config.mjs +55 -0
- package/templates/node/ts/strict/import-typescript/eslint.config.mjs +57 -0
- package/templates/node/ts/strict/typescript/eslint.config.mjs +55 -0
- package/templates/react/js/strict/import/eslint.config.mjs +50 -0
- package/templates/react/js/strict/import-react/eslint.config.mjs +52 -0
- package/templates/react/js/strict/react/eslint.config.mjs +50 -0
- package/templates/react/prettier/js/strict/import/eslint.config.mjs +72 -0
- package/templates/react/prettier/js/strict/import-react/eslint.config.mjs +74 -0
- package/templates/react/prettier/js/strict/react/eslint.config.mjs +72 -0
- package/templates/react/prettier/ts/strict/import/eslint.config.mjs +83 -0
- package/templates/react/prettier/ts/strict/import-react/eslint.config.mjs +85 -0
- package/templates/react/prettier/ts/strict/import-react-typescript/eslint.config.mjs +87 -0
- package/templates/react/prettier/ts/strict/import-typescript/eslint.config.mjs +85 -0
- package/templates/react/prettier/ts/strict/react/eslint.config.mjs +83 -0
- package/templates/react/prettier/ts/strict/react-typescript/eslint.config.mjs +85 -0
- package/templates/react/prettier/ts/strict/typescript/eslint.config.mjs +83 -0
- package/templates/react/ts/strict/import/eslint.config.mjs +61 -0
- package/templates/react/ts/strict/import-react/eslint.config.mjs +63 -0
- package/templates/react/ts/strict/import-react-typescript/eslint.config.mjs +65 -0
- package/templates/react/ts/strict/import-typescript/eslint.config.mjs +63 -0
- package/templates/react/ts/strict/react/eslint.config.mjs +61 -0
- package/templates/react/ts/strict/react-typescript/eslint.config.mjs +63 -0
- package/templates/react/ts/strict/typescript/eslint.config.mjs +61 -0
- /package/templates/legacy/base/js/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/legacy/base/prettier/js/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/legacy/base/prettier/ts/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/legacy/base/ts/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/legacy/react/js/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/legacy/react/prettier/js/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/legacy/react/prettier/ts/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/legacy/react/ts/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/legacy/react-hooks/js/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/legacy/react-hooks/prettier/js/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/legacy/react-hooks/prettier/ts/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/legacy/react-hooks/ts/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/next/js/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/next/prettier/js/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/next/prettier/ts/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/next/ts/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/node/js/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/node/prettier/js/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/node/prettier/ts/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/node/ts/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/react/js/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/react/prettier/js/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/react/prettier/ts/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
- /package/templates/react/ts/{eslint.config.mjs → default/eslint.config.mjs} +0 -0
package/README.md
CHANGED
|
@@ -90,6 +90,18 @@ Options:
|
|
|
90
90
|
|
|
91
91
|
Include the Remix/React Router specific ESLint configuration.
|
|
92
92
|
|
|
93
|
+
--strict-import-config
|
|
94
|
+
|
|
95
|
+
Include the strict Import ESLint configuration.
|
|
96
|
+
|
|
97
|
+
--strict-react-config
|
|
98
|
+
|
|
99
|
+
Include the strict React ESLint configuration.
|
|
100
|
+
|
|
101
|
+
--strict-typescript-config
|
|
102
|
+
|
|
103
|
+
Include the strict TypeScript ESLint configuration.
|
|
104
|
+
|
|
93
105
|
--legacy-base-config
|
|
94
106
|
|
|
95
107
|
Include the legacy Base ESLint configuration.
|
|
@@ -4,6 +4,11 @@ export declare const languages: {
|
|
|
4
4
|
readonly NODE: "node";
|
|
5
5
|
readonly OTHER: "other";
|
|
6
6
|
};
|
|
7
|
+
export declare const strictConfigs: {
|
|
8
|
+
readonly IMPORT: "import";
|
|
9
|
+
readonly REACT: "react";
|
|
10
|
+
readonly TYPESCRIPT: "typescript";
|
|
11
|
+
};
|
|
7
12
|
export declare const configs: {
|
|
8
13
|
readonly BASE: "base";
|
|
9
14
|
readonly NODE: "node";
|
|
@@ -19,6 +24,7 @@ export declare const defaults: {
|
|
|
19
24
|
readonly configType: "extended";
|
|
20
25
|
readonly typescript: true;
|
|
21
26
|
readonly prettier: true;
|
|
27
|
+
readonly strictConfig: false;
|
|
22
28
|
readonly legacyReactHooks: true;
|
|
23
29
|
readonly createESLintFile: true;
|
|
24
30
|
readonly skipInstall: false;
|
package/dist/constants/index.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.legacyLanguages = exports.legacyConfigs = exports.packageManagers = exports.defaults = exports.configTypes = exports.configs = exports.languages = void 0;
|
|
3
|
+
exports.legacyLanguages = exports.legacyConfigs = exports.packageManagers = exports.defaults = exports.configTypes = exports.configs = exports.strictConfigs = exports.languages = void 0;
|
|
4
4
|
exports.languages = {
|
|
5
5
|
REACT: 'react',
|
|
6
6
|
NEXT: 'next',
|
|
7
7
|
NODE: 'node',
|
|
8
8
|
OTHER: 'other',
|
|
9
9
|
};
|
|
10
|
+
exports.strictConfigs = {
|
|
11
|
+
IMPORT: 'import',
|
|
12
|
+
REACT: 'react',
|
|
13
|
+
TYPESCRIPT: 'typescript',
|
|
14
|
+
};
|
|
10
15
|
exports.configs = {
|
|
11
16
|
BASE: 'base',
|
|
12
17
|
NODE: 'node',
|
|
@@ -22,6 +27,7 @@ exports.defaults = {
|
|
|
22
27
|
configType: exports.configTypes.EXTENDED,
|
|
23
28
|
typescript: true,
|
|
24
29
|
prettier: true,
|
|
30
|
+
strictConfig: false,
|
|
25
31
|
legacyReactHooks: true,
|
|
26
32
|
createESLintFile: true,
|
|
27
33
|
skipInstall: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { configs, configTypes, languages, packageManagers } from '../constants';
|
|
1
|
+
import { configs, configTypes, languages, packageManagers, strictConfigs } from '../constants';
|
|
2
2
|
import type { ValueOf } from '../utils/types';
|
|
3
3
|
export declare const configHelp = "\n/**\n * Configuration Rules:\n * 1. Either Base or Node config should be included (choose one).\n * 2. React config can be used with either Next or Remix/React Router (choose one).\n * 3. Including all configs together is not recommended and may lead to conflicts.\n *\n * Summary:\n * - One from: Base | Node\n * - One from: React + (Next | Remix/React Router)\n * - Avoid selecting all configs at once.\n */";
|
|
4
4
|
type GetConfig = (opts: Partial<ProgramOpts>) => GetArgsOutput['config'];
|
|
@@ -18,6 +18,9 @@ export interface ProgramOpts {
|
|
|
18
18
|
reactConfig: true;
|
|
19
19
|
nextConfig: true;
|
|
20
20
|
reactRouterConfig: true;
|
|
21
|
+
strictImportConfig: true;
|
|
22
|
+
strictReactConfig: true;
|
|
23
|
+
strictTypescriptConfig: true;
|
|
21
24
|
legacyBaseConfig: true;
|
|
22
25
|
legacyReactConfig: true;
|
|
23
26
|
legacyReactHooksConfig: true;
|
|
@@ -37,6 +40,7 @@ export interface GetArgsOutput {
|
|
|
37
40
|
configType: ValueOf<typeof configTypes> | null;
|
|
38
41
|
typescript: boolean | null;
|
|
39
42
|
prettier: boolean | null;
|
|
43
|
+
strictConfig: ValueOf<typeof strictConfigs>[] | null;
|
|
40
44
|
language: ValueOf<typeof languages> | null;
|
|
41
45
|
config: ValueOf<typeof configs>[] | null;
|
|
42
46
|
legacyConfig: GetArgsLegacyConfig | null;
|
package/dist/helpers/getArgs.js
CHANGED
|
@@ -32,6 +32,17 @@ const getTypescript = (opts) => {
|
|
|
32
32
|
return false;
|
|
33
33
|
return null;
|
|
34
34
|
};
|
|
35
|
+
const getStrictConfig = (opts) => {
|
|
36
|
+
const { strictImportConfig, strictReactConfig, strictTypescriptConfig } = opts;
|
|
37
|
+
const strictConfig = [];
|
|
38
|
+
if (strictImportConfig)
|
|
39
|
+
strictConfig.push(constants_1.strictConfigs.IMPORT);
|
|
40
|
+
if (strictReactConfig)
|
|
41
|
+
strictConfig.push(constants_1.strictConfigs.REACT);
|
|
42
|
+
if (strictTypescriptConfig)
|
|
43
|
+
strictConfig.push(constants_1.strictConfigs.TYPESCRIPT);
|
|
44
|
+
return strictConfig.length > 0 ? strictConfig : null;
|
|
45
|
+
};
|
|
35
46
|
// Config Help
|
|
36
47
|
exports.configHelp = `
|
|
37
48
|
/**
|
|
@@ -122,6 +133,7 @@ const getArgs = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
122
133
|
configType: getConfigType(opts),
|
|
123
134
|
typescript: getTypescript(opts),
|
|
124
135
|
prettier: opts.prettier ? true : null,
|
|
136
|
+
strictConfig: getStrictConfig(opts),
|
|
125
137
|
language: getLanguage(opts),
|
|
126
138
|
config: (0, exports.getConfig)(opts),
|
|
127
139
|
legacyConfig: getLegacyConfig(opts),
|
|
@@ -5,6 +5,6 @@ interface GetConfigUrlOutput {
|
|
|
5
5
|
path: string;
|
|
6
6
|
url: string;
|
|
7
7
|
}
|
|
8
|
-
export type GetConfigUrl = (args: Pick<NonNullableArgsOutput, 'configType' | 'typescript' | 'prettier' | 'language' | 'legacyConfig'>) => GetConfigUrlOutput | null;
|
|
8
|
+
export type GetConfigUrl = (args: Pick<NonNullableArgsOutput, 'configType' | 'typescript' | 'prettier' | 'strictConfig' | 'language' | 'legacyConfig'>) => GetConfigUrlOutput | null;
|
|
9
9
|
declare const getConfigUrl: GetConfigUrl;
|
|
10
10
|
export default getConfigUrl;
|
|
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.baseGithubUrl = exports.eslintConfigName = void 0;
|
|
7
7
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
|
+
const constants_2 = require("../lib/templates/constants");
|
|
9
10
|
exports.eslintConfigName = 'eslint.config.mjs';
|
|
10
11
|
exports.baseGithubUrl = 'https://github.com/NishargShah/eslint-config-airbnb-extended/tree/master/packages/create-airbnb-x-config/templates';
|
|
11
12
|
const getConfigUrl = (args) => {
|
|
12
|
-
const { configType, typescript, prettier, language, legacyConfig } = args;
|
|
13
|
+
const { configType, typescript, prettier, strictConfig, language, legacyConfig } = args;
|
|
13
14
|
const isLegacy = configType === constants_1.configTypes.LEGACY;
|
|
14
15
|
if (!isLegacy && language === constants_1.languages.OTHER)
|
|
15
16
|
return null;
|
|
@@ -26,10 +27,17 @@ const getConfigUrl = (args) => {
|
|
|
26
27
|
return constants_1.legacyLanguages.REACT_HOOKS;
|
|
27
28
|
return null;
|
|
28
29
|
})();
|
|
30
|
+
const strictOrDefaultText = (() => {
|
|
31
|
+
if (!strictConfig || strictConfig.length === 0)
|
|
32
|
+
return [constants_2.subFolders.DEFAULT];
|
|
33
|
+
const strictFolder = strictConfig.sort((a, b) => a.localeCompare(b)).join('-');
|
|
34
|
+
return [constants_2.subFolders.STRICT, strictFolder];
|
|
35
|
+
})();
|
|
29
36
|
const path = [
|
|
30
37
|
...(isLegacy ? [constants_1.configTypes.LEGACY, legacyLanguage] : [language]),
|
|
31
38
|
prettierText,
|
|
32
39
|
tsOrJsText,
|
|
40
|
+
...strictOrDefaultText,
|
|
33
41
|
exports.eslintConfigName,
|
|
34
42
|
]
|
|
35
43
|
.filter(Boolean)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
/**
|
|
3
3
|
* Program Command
|
|
4
|
-
* @example: pnpm cli:start --extended --legacy --ts --js --prettier --react --remix --next --node --base-config --node-config --react-config --remix-config --
|
|
4
|
+
* @example: pnpm cli:start --extended --legacy --ts --js --prettier --react --remix --next --node --base-config --node-config --react-config --next-config --remix-config --strict-import-config --strict-react-config --strict-typescript-config --legacy-base-config --legacy-react-config --legacy-react-hooks-config --use-npm --use-yarn --use-pnpm --use-bun --create-eslint-file --skip-install
|
|
5
5
|
*/
|
|
6
6
|
declare const program: Command;
|
|
7
7
|
export default program;
|
package/dist/helpers/program.js
CHANGED
|
@@ -5,7 +5,7 @@ const getConfigUrl_1 = require("../helpers/getConfigUrl");
|
|
|
5
5
|
const package_json_1 = require("../package.json");
|
|
6
6
|
/**
|
|
7
7
|
* Program Command
|
|
8
|
-
* @example: pnpm cli:start --extended --legacy --ts --js --prettier --react --remix --next --node --base-config --node-config --react-config --remix-config --
|
|
8
|
+
* @example: pnpm cli:start --extended --legacy --ts --js --prettier --react --remix --next --node --base-config --node-config --react-config --next-config --remix-config --strict-import-config --strict-react-config --strict-typescript-config --legacy-base-config --legacy-react-config --legacy-react-hooks-config --use-npm --use-yarn --use-pnpm --use-bun --create-eslint-file --skip-install
|
|
9
9
|
*/
|
|
10
10
|
const program = new commander_1.Command()
|
|
11
11
|
.name(package_json_1.name)
|
|
@@ -25,6 +25,9 @@ const program = new commander_1.Command()
|
|
|
25
25
|
.option('--react-config', 'Include the React specific ESLint configuration.')
|
|
26
26
|
.option('--next-config', 'Include the Next.js specific ESLint configuration.')
|
|
27
27
|
.option('--remix-config, --react-router-config', 'Include the Remix/React Router specific ESLint configuration.')
|
|
28
|
+
.option('--strict-import-config', 'Include the strict Import ESLint configuration.')
|
|
29
|
+
.option('--strict-react-config', 'Include the strict React ESLint configuration.')
|
|
30
|
+
.option('--strict-typescript-config', 'Include the strict TypeScript ESLint configuration.')
|
|
28
31
|
.option('--legacy-base-config', 'Include the legacy Base ESLint configuration.')
|
|
29
32
|
.option('--legacy-react-config', 'Include the legacy React ESLint configuration.')
|
|
30
33
|
.option('--legacy-react-hooks-config', 'Include the legacy React Hooks ESLint configuration.')
|
package/dist/index.js
CHANGED
|
@@ -194,6 +194,60 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
194
194
|
args = Object.assign(Object.assign({}, args), { config: [] });
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
+
if (!args.strictConfig) {
|
|
198
|
+
const { hasStrictConfig } = yield (0, prompts_1.default)({
|
|
199
|
+
type: 'toggle',
|
|
200
|
+
name: 'hasStrictConfig',
|
|
201
|
+
message: `Do you want to add ${picocolors_1.default.cyan('strict')} configs?`,
|
|
202
|
+
initial: constants_1.defaults.strictConfig,
|
|
203
|
+
active: 'Yes',
|
|
204
|
+
inactive: 'No',
|
|
205
|
+
onState: utils_1.onPromptState,
|
|
206
|
+
}, {
|
|
207
|
+
onCancel: utils_1.onCancel,
|
|
208
|
+
});
|
|
209
|
+
if (hasStrictConfig) {
|
|
210
|
+
const { strictConfig } = yield (0, prompts_1.default)({
|
|
211
|
+
type: 'multiselect',
|
|
212
|
+
name: 'strictConfig',
|
|
213
|
+
message: 'Select Strict Configs:',
|
|
214
|
+
min: 1,
|
|
215
|
+
choices: [
|
|
216
|
+
{
|
|
217
|
+
title: 'Import',
|
|
218
|
+
description: picocolors_1.default.yellowBright('Strict Import config'),
|
|
219
|
+
value: constants_1.strictConfigs.IMPORT,
|
|
220
|
+
},
|
|
221
|
+
...(args.language &&
|
|
222
|
+
[constants_1.languages.REACT, constants_1.languages.NEXT].includes(args.language)
|
|
223
|
+
? [
|
|
224
|
+
{
|
|
225
|
+
title: 'React',
|
|
226
|
+
description: picocolors_1.default.cyanBright('Strict React config'),
|
|
227
|
+
value: constants_1.strictConfigs.REACT,
|
|
228
|
+
},
|
|
229
|
+
]
|
|
230
|
+
: []),
|
|
231
|
+
...(args.typescript
|
|
232
|
+
? [
|
|
233
|
+
{
|
|
234
|
+
title: 'TypeScript',
|
|
235
|
+
description: picocolors_1.default.blueBright('Strict TypeScript config'),
|
|
236
|
+
value: constants_1.strictConfigs.TYPESCRIPT,
|
|
237
|
+
},
|
|
238
|
+
]
|
|
239
|
+
: []),
|
|
240
|
+
],
|
|
241
|
+
onState: utils_1.onPromptState,
|
|
242
|
+
}, {
|
|
243
|
+
onCancel: utils_1.onCancel,
|
|
244
|
+
});
|
|
245
|
+
args = Object.assign(Object.assign({}, args), { strictConfig });
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
args = Object.assign(Object.assign({}, args), { strictConfig: [] });
|
|
249
|
+
}
|
|
250
|
+
}
|
|
197
251
|
}
|
|
198
252
|
if (args.configType === constants_1.configTypes.LEGACY) {
|
|
199
253
|
if (!args.legacyConfig || args.legacyConfig.base === null || args.legacyConfig.react === null) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Content } from '../../lib/templates/contentFormatter';
|
|
2
|
+
import type { GetContentParams } from '../../lib/templates/getContent';
|
|
3
|
+
type Config = (params: GetContentParams) => Content;
|
|
4
|
+
export declare const startingComments: string[];
|
|
5
|
+
export declare const imports: Config;
|
|
6
|
+
export declare const gitignoreCode: string[];
|
|
7
|
+
export declare const jsConfig: Config;
|
|
8
|
+
export declare const reactConfig: Config;
|
|
9
|
+
export declare const nodeConfig: (string | string[])[];
|
|
10
|
+
export declare const typescriptConfig: Config;
|
|
11
|
+
export declare const prettierConfig: (string | (string | (string | string[])[])[])[];
|
|
12
|
+
export declare const defaultConfig: Config;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultConfig = exports.prettierConfig = exports.typescriptConfig = exports.nodeConfig = exports.reactConfig = exports.jsConfig = exports.gitignoreCode = exports.imports = exports.startingComments = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const constants_2 = require("../../lib/templates/constants");
|
|
6
|
+
// STARTING COMMENTS
|
|
7
|
+
exports.startingComments = [
|
|
8
|
+
'/**',
|
|
9
|
+
' * THIS FILE WAS AUTO-GENERATED.',
|
|
10
|
+
' * PLEASE DO NOT EDIT IT MANUALLY.',
|
|
11
|
+
' * ===============================',
|
|
12
|
+
" * IF YOU'RE COPYING THIS INTO AN ESLINT CONFIG, REMOVE THIS COMMENT BLOCK.",
|
|
13
|
+
' */',
|
|
14
|
+
];
|
|
15
|
+
// IMPORTS
|
|
16
|
+
const imports = ({ type, configurations, strictConfig }) => {
|
|
17
|
+
const isLegacy = type === constants_1.configTypes.LEGACY;
|
|
18
|
+
const hasStrictConfig = strictConfig.length > 0;
|
|
19
|
+
const importStatement = (() => {
|
|
20
|
+
if (isLegacy)
|
|
21
|
+
return "import { configs } from 'eslint-config-airbnb-extended/legacy';";
|
|
22
|
+
if (hasStrictConfig) {
|
|
23
|
+
return "import { configs, plugins, rules } from 'eslint-config-airbnb-extended';";
|
|
24
|
+
}
|
|
25
|
+
return "import { configs, plugins } from 'eslint-config-airbnb-extended';";
|
|
26
|
+
})();
|
|
27
|
+
return [
|
|
28
|
+
"import path from 'node:path';",
|
|
29
|
+
'',
|
|
30
|
+
"import { includeIgnoreFile } from '@eslint/compat';",
|
|
31
|
+
"import js from '@eslint/js';",
|
|
32
|
+
importStatement,
|
|
33
|
+
...(configurations.prettier
|
|
34
|
+
? [
|
|
35
|
+
"import { rules as prettierConfigRules } from 'eslint-config-prettier';",
|
|
36
|
+
"import prettierPlugin from 'eslint-plugin-prettier';",
|
|
37
|
+
]
|
|
38
|
+
: []),
|
|
39
|
+
];
|
|
40
|
+
};
|
|
41
|
+
exports.imports = imports;
|
|
42
|
+
// GITIGNORE CONFIG
|
|
43
|
+
exports.gitignoreCode = ["const gitignorePath = path.resolve('.', '.gitignore');"];
|
|
44
|
+
// JAVASCRIPT CONFIG
|
|
45
|
+
const jsConfig = ({ type, language, strictConfig }) => {
|
|
46
|
+
const isLegacy = type === constants_1.configTypes.LEGACY;
|
|
47
|
+
const hasStrictImportConfig = strictConfig.includes(constants_1.strictConfigs.IMPORT);
|
|
48
|
+
const jsArray = (() => {
|
|
49
|
+
if (isLegacy) {
|
|
50
|
+
return language === constants_1.legacyLanguages.BASE
|
|
51
|
+
? ['// Airbnb Base Recommended Config', '...configs.base.recommended,']
|
|
52
|
+
: [];
|
|
53
|
+
}
|
|
54
|
+
return [
|
|
55
|
+
'// Stylistic Plugin',
|
|
56
|
+
'plugins.stylistic,',
|
|
57
|
+
'// Import X Plugin',
|
|
58
|
+
'plugins.importX,',
|
|
59
|
+
'// Airbnb Base Recommended Config',
|
|
60
|
+
'...configs.base.recommended,',
|
|
61
|
+
...(hasStrictImportConfig ? ['// Strict Import Config', 'rules.base.importsStrict,'] : []),
|
|
62
|
+
];
|
|
63
|
+
})();
|
|
64
|
+
return [
|
|
65
|
+
'const jsConfig = [',
|
|
66
|
+
[
|
|
67
|
+
'// ESLint Recommended Rules',
|
|
68
|
+
'{',
|
|
69
|
+
["name: 'js/config',", '...js.configs.recommended,'],
|
|
70
|
+
'},',
|
|
71
|
+
...jsArray,
|
|
72
|
+
],
|
|
73
|
+
'];',
|
|
74
|
+
];
|
|
75
|
+
};
|
|
76
|
+
exports.jsConfig = jsConfig;
|
|
77
|
+
// REACT & NEXT CONFIG
|
|
78
|
+
const reactConfig = ({ type, language, strictConfig }) => {
|
|
79
|
+
const isLegacy = type === constants_1.configTypes.LEGACY;
|
|
80
|
+
const isNextJs = language === constants_1.languages.NEXT;
|
|
81
|
+
const hasStrictReactConfig = strictConfig.includes(constants_1.strictConfigs.REACT);
|
|
82
|
+
const reactArray = [
|
|
83
|
+
'// React Plugin',
|
|
84
|
+
'plugins.react,',
|
|
85
|
+
'// React Hooks Plugin',
|
|
86
|
+
'plugins.reactHooks,',
|
|
87
|
+
'// React JSX A11y Plugin',
|
|
88
|
+
'plugins.reactA11y,',
|
|
89
|
+
];
|
|
90
|
+
const nextArray = ['// Next Plugin', 'plugins.next,'];
|
|
91
|
+
const legacyArray = [
|
|
92
|
+
'const reactConfig = [',
|
|
93
|
+
['// Airbnb React Recommended Config', '...configs.react.recommended,'],
|
|
94
|
+
language === constants_1.legacyLanguages.REACT_HOOKS
|
|
95
|
+
? ['// Airbnb React Hooks Config', '...configs.react.hooks,']
|
|
96
|
+
: [],
|
|
97
|
+
'];',
|
|
98
|
+
];
|
|
99
|
+
const extendedArray = [
|
|
100
|
+
`const ${language}Config = [`,
|
|
101
|
+
[
|
|
102
|
+
...reactArray,
|
|
103
|
+
...(isNextJs ? nextArray : []),
|
|
104
|
+
`// Airbnb ${isNextJs ? 'Next' : 'React'} Recommended Config`,
|
|
105
|
+
`...configs.${language}.recommended,`,
|
|
106
|
+
...(hasStrictReactConfig ? ['// Strict React Config', 'rules.react.strict,'] : []),
|
|
107
|
+
],
|
|
108
|
+
'];',
|
|
109
|
+
];
|
|
110
|
+
return isLegacy ? legacyArray : extendedArray;
|
|
111
|
+
};
|
|
112
|
+
exports.reactConfig = reactConfig;
|
|
113
|
+
// NODE CONFIG
|
|
114
|
+
exports.nodeConfig = [
|
|
115
|
+
'const nodeConfig = [',
|
|
116
|
+
[
|
|
117
|
+
'// Node Plugin',
|
|
118
|
+
'plugins.node,',
|
|
119
|
+
'// Airbnb Node Recommended Config',
|
|
120
|
+
'...configs.node.recommended,',
|
|
121
|
+
],
|
|
122
|
+
'];',
|
|
123
|
+
];
|
|
124
|
+
// TYPESCRIPT CONFIG
|
|
125
|
+
const typescriptConfig = ({ type, language, strictConfig }) => {
|
|
126
|
+
const isLegacy = type === constants_1.configTypes.LEGACY;
|
|
127
|
+
const reactArray = ['// Airbnb React TypeScript Config', '...configs.react.typescript,'];
|
|
128
|
+
const nextArray = ['// Airbnb Next TypeScript Config', '...configs.next.typescript,'];
|
|
129
|
+
const hasStrictTypescriptConfig = strictConfig.includes(constants_1.strictConfigs.TYPESCRIPT);
|
|
130
|
+
const legacyArray = [
|
|
131
|
+
'const typescriptConfig = [',
|
|
132
|
+
language === constants_1.legacyLanguages.BASE
|
|
133
|
+
? ['// Airbnb Base TypeScript Config', '...configs.base.typescript,']
|
|
134
|
+
: ['// Airbnb React TypeScript Config', '...configs.react.typescript,'],
|
|
135
|
+
'];',
|
|
136
|
+
];
|
|
137
|
+
const extendedArray = [
|
|
138
|
+
'const typescriptConfig = [',
|
|
139
|
+
[
|
|
140
|
+
'// TypeScript ESLint Plugin',
|
|
141
|
+
'plugins.typescriptEslint,',
|
|
142
|
+
'// Airbnb Base TypeScript Config',
|
|
143
|
+
'...configs.base.typescript,',
|
|
144
|
+
...(hasStrictTypescriptConfig
|
|
145
|
+
? ['// Strict TypeScript Config', 'rules.typescript.typescriptEslintStrict,']
|
|
146
|
+
: []),
|
|
147
|
+
...(language === constants_1.languages.REACT ? reactArray : []),
|
|
148
|
+
...(language === constants_1.languages.NEXT ? nextArray : []),
|
|
149
|
+
],
|
|
150
|
+
'];',
|
|
151
|
+
];
|
|
152
|
+
return isLegacy ? legacyArray : extendedArray;
|
|
153
|
+
};
|
|
154
|
+
exports.typescriptConfig = typescriptConfig;
|
|
155
|
+
// Prettier Config
|
|
156
|
+
exports.prettierConfig = [
|
|
157
|
+
'const prettierConfig = [',
|
|
158
|
+
[
|
|
159
|
+
'// Prettier Plugin',
|
|
160
|
+
'{',
|
|
161
|
+
["name: 'prettier/plugin/config',", 'plugins: {', ['prettier: prettierPlugin,'], '},'],
|
|
162
|
+
'},',
|
|
163
|
+
],
|
|
164
|
+
[
|
|
165
|
+
'// Prettier Config',
|
|
166
|
+
'{',
|
|
167
|
+
[
|
|
168
|
+
"name: 'prettier/config',",
|
|
169
|
+
'rules: {',
|
|
170
|
+
['...prettierConfigRules,', "'prettier/prettier': 'error',"],
|
|
171
|
+
'},',
|
|
172
|
+
],
|
|
173
|
+
'},',
|
|
174
|
+
],
|
|
175
|
+
'];',
|
|
176
|
+
];
|
|
177
|
+
// DEFAULT CONFIG
|
|
178
|
+
const defaultConfig = ({ type, language, languagePreference, configurations }) => {
|
|
179
|
+
const isLegacy = type === constants_1.configTypes.LEGACY;
|
|
180
|
+
const reactArray = ['// React Config', '...reactConfig,'];
|
|
181
|
+
const nextArray = ['// Next Config', '...nextConfig,'];
|
|
182
|
+
const typescriptArray = ['// TypeScript Config', '...typescriptConfig,'];
|
|
183
|
+
const nodeArray = ['// Node Config', '...nodeConfig,'];
|
|
184
|
+
const prettierArray = ['// Prettier Config', '...prettierConfig,'];
|
|
185
|
+
return [
|
|
186
|
+
'export default [',
|
|
187
|
+
[
|
|
188
|
+
'// Ignore .gitignore files/folder in eslint',
|
|
189
|
+
'includeIgnoreFile(gitignorePath),',
|
|
190
|
+
'// Javascript Config',
|
|
191
|
+
'...jsConfig,',
|
|
192
|
+
...((isLegacy &&
|
|
193
|
+
[constants_1.legacyLanguages.REACT, constants_1.legacyLanguages.REACT_HOOKS].includes(language)) ||
|
|
194
|
+
(!isLegacy && language === constants_1.languages.REACT)
|
|
195
|
+
? reactArray
|
|
196
|
+
: []),
|
|
197
|
+
...(!isLegacy && language === constants_1.languages.NEXT ? nextArray : []),
|
|
198
|
+
...(!isLegacy && language === constants_1.languages.NODE ? nodeArray : []),
|
|
199
|
+
...(languagePreference === constants_2.languagePreferences.TYPESCRIPT ? typescriptArray : []),
|
|
200
|
+
...(configurations.prettier ? prettierArray : []),
|
|
201
|
+
],
|
|
202
|
+
'];',
|
|
203
|
+
];
|
|
204
|
+
};
|
|
205
|
+
exports.defaultConfig = defaultConfig;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const templateConstants: {
|
|
2
|
+
readonly FOLDER_NAME: "templates";
|
|
3
|
+
};
|
|
4
|
+
export declare const languagePreferences: {
|
|
5
|
+
readonly JAVASCRIPT: "js";
|
|
6
|
+
readonly TYPESCRIPT: "ts";
|
|
7
|
+
};
|
|
8
|
+
export declare const subFolders: {
|
|
9
|
+
readonly DEFAULT: "default";
|
|
10
|
+
readonly PRETTIER: "prettier";
|
|
11
|
+
readonly BASE: "base";
|
|
12
|
+
readonly REACT: "react";
|
|
13
|
+
readonly REACT_HOOKS: "react-hooks";
|
|
14
|
+
readonly STRICT: "strict";
|
|
15
|
+
readonly STRICT_IMPORT: "import";
|
|
16
|
+
readonly STRICT_IMPORT_REACT: "import-react";
|
|
17
|
+
readonly STRICT_IMPORT_TYPESCRIPT: "import-typescript";
|
|
18
|
+
readonly STRICT_IMPORT_REACT_TYPESCRIPT: "import-react-typescript";
|
|
19
|
+
readonly STRICT_REACT: "react";
|
|
20
|
+
readonly STRICT_REACT_TYPESCRIPT: "react-typescript";
|
|
21
|
+
readonly STRICT_TYPESCRIPT: "typescript";
|
|
22
|
+
readonly JAVASCRIPT: "js";
|
|
23
|
+
readonly TYPESCRIPT: "ts";
|
|
24
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subFolders = exports.languagePreferences = exports.templateConstants = void 0;
|
|
4
|
+
exports.templateConstants = {
|
|
5
|
+
FOLDER_NAME: 'templates',
|
|
6
|
+
};
|
|
7
|
+
exports.languagePreferences = {
|
|
8
|
+
JAVASCRIPT: 'js',
|
|
9
|
+
TYPESCRIPT: 'ts',
|
|
10
|
+
};
|
|
11
|
+
exports.subFolders = Object.assign(Object.assign({}, exports.languagePreferences), { DEFAULT: 'default', PRETTIER: 'prettier', BASE: 'base', REACT: 'react', REACT_HOOKS: 'react-hooks', STRICT: 'strict', STRICT_IMPORT: 'import', STRICT_IMPORT_REACT: 'import-react', STRICT_IMPORT_TYPESCRIPT: 'import-typescript', STRICT_IMPORT_REACT_TYPESCRIPT: 'import-react-typescript', STRICT_REACT: 'react', STRICT_REACT_TYPESCRIPT: 'react-typescript', STRICT_TYPESCRIPT: 'typescript' });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const contentFormatter = (content, level = 0) => content.reduce((acc, val) => {
|
|
4
|
+
if (typeof val === 'string') {
|
|
5
|
+
acc.push(`${' '.repeat(level * 2)}${val}`);
|
|
6
|
+
}
|
|
7
|
+
if (Array.isArray(val)) {
|
|
8
|
+
acc.push(...contentFormatter(val, level + 1));
|
|
9
|
+
}
|
|
10
|
+
return acc;
|
|
11
|
+
}, []);
|
|
12
|
+
exports.default = contentFormatter;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
16
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
17
|
+
const constants_1 = require("../../lib/templates/constants");
|
|
18
|
+
const getFolders_1 = __importDefault(require("../../lib/templates/getFolders"));
|
|
19
|
+
const { FOLDER_NAME } = constants_1.templateConstants;
|
|
20
|
+
const createDirectories = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
if (node_fs_1.default.existsSync(FOLDER_NAME)) {
|
|
22
|
+
yield promises_1.default.rm(FOLDER_NAME, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
const allFolders = (0, getFolders_1.default)();
|
|
25
|
+
yield Promise.all(allFolders.map((folder) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
return promises_1.default.mkdir(folder.path, {
|
|
27
|
+
recursive: true,
|
|
28
|
+
});
|
|
29
|
+
})));
|
|
30
|
+
});
|
|
31
|
+
exports.default = createDirectories;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { GetContentParams } from '../../lib/templates/getContent';
|
|
2
|
+
interface FolderMeta extends Partial<Pick<GetContentParams, 'language' | 'languagePreference' | 'strictConfig'>> {
|
|
3
|
+
configType?: GetContentParams['type'];
|
|
4
|
+
hasPrettier?: NonNullable<GetContentParams['configurations']>['prettier'];
|
|
5
|
+
}
|
|
6
|
+
interface Folder {
|
|
7
|
+
meta?: FolderMeta;
|
|
8
|
+
data?: Folders;
|
|
9
|
+
cond?: (folder: Required<Pick<Folder, 'meta'>>) => boolean;
|
|
10
|
+
}
|
|
11
|
+
export type Folders = Record<string, Folder>;
|
|
12
|
+
export interface GetFolder {
|
|
13
|
+
path: string;
|
|
14
|
+
meta: FolderMeta;
|
|
15
|
+
}
|
|
16
|
+
type GetAllFoldersOutput = GetFolder[];
|
|
17
|
+
type GetAllFolders = (folders: Folders, prefix: string[], meta?: FolderMeta) => GetAllFoldersOutput;
|
|
18
|
+
declare const getAllFolders: GetAllFolders;
|
|
19
|
+
export default getAllFolders;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getAllFolders = (folders, prefix, meta = {}) => Object.entries(folders).reduce((acc, val) => {
|
|
4
|
+
const [key, value] = val;
|
|
5
|
+
const prefixes = [...prefix, key];
|
|
6
|
+
const condition = value.cond ? value.cond({ meta }) : true;
|
|
7
|
+
const values = (() => {
|
|
8
|
+
if (value.data && condition) {
|
|
9
|
+
return Object.entries(value.data).reduce((subAcc, subVal) => {
|
|
10
|
+
const [subKey, subValue] = subVal;
|
|
11
|
+
const subFolders = { [subKey]: subValue };
|
|
12
|
+
const subMeta = Object.assign(Object.assign(Object.assign({}, meta), value.meta), subValue.meta);
|
|
13
|
+
const subCondition = subValue.cond ? subValue.cond({ meta: subMeta }) : true;
|
|
14
|
+
if (subCondition)
|
|
15
|
+
subAcc.push(...getAllFolders(subFolders, prefixes, subMeta));
|
|
16
|
+
return subAcc;
|
|
17
|
+
}, []);
|
|
18
|
+
}
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
path: prefixes.join('/'),
|
|
22
|
+
meta,
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
})();
|
|
26
|
+
acc.push(...values);
|
|
27
|
+
return acc;
|
|
28
|
+
}, []);
|
|
29
|
+
exports.default = getAllFolders;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { configTypes, languages, legacyLanguages } from '../../constants';
|
|
2
|
+
import { languagePreferences } from '../../lib/templates/constants';
|
|
3
|
+
import type { strictConfigs } from '../../constants';
|
|
4
|
+
import type { ValueOf } from '../../utils/types';
|
|
5
|
+
interface GetContentConfigurations {
|
|
6
|
+
prettier: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface GetContentParams {
|
|
9
|
+
type: ValueOf<typeof configTypes>;
|
|
10
|
+
language: Exclude<ValueOf<typeof languages>, typeof languages.OTHER> | ValueOf<typeof legacyLanguages>;
|
|
11
|
+
languagePreference: ValueOf<typeof languagePreferences>;
|
|
12
|
+
configurations: GetContentConfigurations;
|
|
13
|
+
strictConfig: ValueOf<typeof strictConfigs>[];
|
|
14
|
+
}
|
|
15
|
+
type GetContent = (params: GetContentParams) => string;
|
|
16
|
+
declare const getContent: GetContent;
|
|
17
|
+
export default getContent;
|