@dcdavidev/eslint-plugin 0.0.0-stage → 0.3.1
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/LICENSE +21 -0
- package/README.md +109 -2
- package/dist/configs/css.d.ts +12 -0
- package/dist/configs/css.d.ts.map +1 -0
- package/dist/configs/css.js +24 -0
- package/dist/configs/css.js.map +1 -0
- package/dist/configs/index.d.ts +14 -0
- package/dist/configs/index.d.ts.map +1 -0
- package/dist/configs/index.js +22 -0
- package/dist/configs/index.js.map +1 -0
- package/dist/configs/javascript.d.ts +12 -0
- package/dist/configs/javascript.d.ts.map +1 -0
- package/dist/configs/javascript.js +103 -0
- package/dist/configs/javascript.js.map +1 -0
- package/dist/configs/json.d.ts +14 -0
- package/dist/configs/json.d.ts.map +1 -0
- package/dist/configs/json.js +39 -0
- package/dist/configs/json.js.map +1 -0
- package/dist/configs/markdown.d.ts +12 -0
- package/dist/configs/markdown.d.ts.map +1 -0
- package/dist/configs/markdown.js +24 -0
- package/dist/configs/markdown.js.map +1 -0
- package/dist/configs/nextjs.d.ts +14 -0
- package/dist/configs/nextjs.d.ts.map +1 -0
- package/dist/configs/nextjs.js +69 -0
- package/dist/configs/nextjs.js.map +1 -0
- package/dist/configs/recommended.d.ts +14 -0
- package/dist/configs/recommended.d.ts.map +1 -0
- package/dist/configs/recommended.js +30 -0
- package/dist/configs/recommended.js.map +1 -0
- package/dist/configs/shell-bash.d.ts +12 -0
- package/dist/configs/shell-bash.d.ts.map +1 -0
- package/dist/configs/shell-bash.js +24 -0
- package/dist/configs/shell-bash.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/define-imports.d.ts +26 -0
- package/dist/lib/define-imports.d.ts.map +1 -0
- package/dist/lib/define-imports.js +76 -0
- package/dist/lib/define-imports.js.map +1 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +5 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +94 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file ESLint flat configuration for shell scripts using `@eslint/shell`.
|
|
3
|
+
*/
|
|
4
|
+
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
5
|
+
import prettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
6
|
+
import { ignores } from '@dcdavidev/shared-spells';
|
|
7
|
+
import shell from '@eslint/shell';
|
|
8
|
+
/**
|
|
9
|
+
* Shell (Bash) flat ESLint configuration.
|
|
10
|
+
* Lints `.sh` and `.bash` files with the `@eslint/shell` recommended
|
|
11
|
+
* rules and formats them through Prettier.
|
|
12
|
+
*/
|
|
13
|
+
export const shellBash = defineConfig([
|
|
14
|
+
globalIgnores([...ignores.all]),
|
|
15
|
+
{
|
|
16
|
+
files: ['**/*.sh', '**/*.bash'],
|
|
17
|
+
plugins: { shell: shell },
|
|
18
|
+
language: 'shell/bash',
|
|
19
|
+
extends: ['shell/recommended'],
|
|
20
|
+
},
|
|
21
|
+
prettierRecommended,
|
|
22
|
+
]);
|
|
23
|
+
export default shellBash;
|
|
24
|
+
//# sourceMappingURL=shell-bash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-bash.js","sources":["../../src/configs/shell-bash.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,mBAAmB,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,MAAM,eAAe,CAAC;AAElC;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAoB,YAAY,CAAC;IACrD,aAAa,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE/B;QACE,KAAK,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC;QAC/B,OAAO,EAAE,EAAE,KAAK,EAAE,KAAiC,EAAE;QACrD,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE,CAAC,mBAAmB,CAAC;KAC/B;IAED,mBAAmB;CACpB,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Entry point of `@dcdavidev/eslint-plugin`: exposes the plugin object
|
|
3
|
+
* and its shareable flat configurations.
|
|
4
|
+
*/
|
|
5
|
+
import type { ESLint } from 'eslint';
|
|
6
|
+
import { configs } from './configs/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Extended ESLint plugin type with strongly-typed configurations dictionary.
|
|
9
|
+
*/
|
|
10
|
+
export type Plugin = ESLint.Plugin & {
|
|
11
|
+
/**
|
|
12
|
+
* Shareable flat configurations exposed by the plugin, keyed by name.
|
|
13
|
+
*/
|
|
14
|
+
configs: typeof configs;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* ESLint plugin object exposing shareable flat configurations for spellbook.
|
|
18
|
+
*/
|
|
19
|
+
export declare const plugin: Plugin;
|
|
20
|
+
export default plugin;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAkB7C;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG;IACnC;;OAEG;IACH,OAAO,EAAE,OAAO,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,MASpB,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Entry point of `@dcdavidev/eslint-plugin`: exposes the plugin object
|
|
3
|
+
* and its shareable flat configurations.
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
7
|
+
import { configs } from './configs/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Absolute path to the package `package.json`, resolved from this module.
|
|
10
|
+
*/
|
|
11
|
+
const packageJsonPath = fileURLToPath(new URL('../package.json', import.meta.url));
|
|
12
|
+
/**
|
|
13
|
+
* Parsed `package.json` metadata for `@dcdavidev/eslint-plugin`.
|
|
14
|
+
*/
|
|
15
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
16
|
+
/**
|
|
17
|
+
* ESLint plugin object exposing shareable flat configurations for spellbook.
|
|
18
|
+
*/
|
|
19
|
+
export const plugin = {
|
|
20
|
+
meta: {
|
|
21
|
+
name: packageJson.name,
|
|
22
|
+
version: packageJson.version,
|
|
23
|
+
namespace: 'dcdavidev',
|
|
24
|
+
},
|
|
25
|
+
configs,
|
|
26
|
+
rules: {},
|
|
27
|
+
processors: {},
|
|
28
|
+
};
|
|
29
|
+
export default plugin;
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAI9C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;GAEG;AACH,MAAM,eAAe,GAAG,aAAa,CACnC,IAAI,GAAG,CAAC,iBAAiB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAC5C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAInE,CAAC;AAYF;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAW;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,SAAS,EAAE,WAAW;KACvB;IACD,OAAO;IACP,KAAK,EAAE,EAAE;IACT,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Composes regex groups for `eslint-plugin-simple-import-sort` using
|
|
3
|
+
* spellbook import spell.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Valid import group representation for composing `simple-import-sort` regexes.
|
|
7
|
+
*/
|
|
8
|
+
export type ImportGroupInput = readonly string[] | string[] | string | null | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Composes an array of regex groups for `eslint-plugin-simple-import-sort`.
|
|
11
|
+
* Filters empty groups and formats each package name into an anchored regex.
|
|
12
|
+
*
|
|
13
|
+
* @param groups - Array of import categories or package lists.
|
|
14
|
+
* @returns Array of regex groups for `simple-import-sort/imports`.
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const groups = defineImports(
|
|
18
|
+
* imports.dotenv,
|
|
19
|
+
* imports.builtinModules,
|
|
20
|
+
* imports.uiFrameworks,
|
|
21
|
+
* );
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function defineImports(...groups: (ImportGroupInput | ImportGroupInput[])[]): string[][];
|
|
25
|
+
export default defineImports;
|
|
26
|
+
//# sourceMappingURL=define-imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-imports.d.ts","sources":["../../src/lib/define-imports.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAC1B,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAyB3D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,GAAG,MAAM,EAAE,CAAC,gBAAgB,GAAG,gBAAgB,EAAE,CAAC,EAAE,GACnD,MAAM,EAAE,EAAE,CA2CZ;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Composes regex groups for `eslint-plugin-simple-import-sort` using
|
|
3
|
+
* spellbook import spell.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Normalizes a package pattern or token into a regex suitable for `simple-import-sort`.
|
|
7
|
+
*
|
|
8
|
+
* @param pattern - Raw pattern or package name.
|
|
9
|
+
* @returns Regex pattern string.
|
|
10
|
+
*/
|
|
11
|
+
function formatSimpleImportRegex(pattern) {
|
|
12
|
+
if (pattern === '' ||
|
|
13
|
+
pattern.startsWith('^') ||
|
|
14
|
+
pattern.startsWith(String.raw `^\u0000`) ||
|
|
15
|
+
pattern.startsWith('<')) {
|
|
16
|
+
return pattern === '<THIRD_PARTY_MODULES>' ? '^[a-z]' : pattern;
|
|
17
|
+
}
|
|
18
|
+
if (pattern === 'node:') {
|
|
19
|
+
return '^node:';
|
|
20
|
+
}
|
|
21
|
+
return pattern.startsWith('.') ? String.raw `^\.?\.\/` : `^${pattern}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Composes an array of regex groups for `eslint-plugin-simple-import-sort`.
|
|
25
|
+
* Filters empty groups and formats each package name into an anchored regex.
|
|
26
|
+
*
|
|
27
|
+
* @param groups - Array of import categories or package lists.
|
|
28
|
+
* @returns Array of regex groups for `simple-import-sort/imports`.
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const groups = defineImports(
|
|
32
|
+
* imports.dotenv,
|
|
33
|
+
* imports.builtinModules,
|
|
34
|
+
* imports.uiFrameworks,
|
|
35
|
+
* );
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function defineImports(...groups) {
|
|
39
|
+
const result = [];
|
|
40
|
+
const rawGroups = groups.length === 1 &&
|
|
41
|
+
Array.isArray(groups[0]) &&
|
|
42
|
+
Array.isArray(groups[0][0])
|
|
43
|
+
? groups[0]
|
|
44
|
+
: groups;
|
|
45
|
+
for (const group of rawGroups) {
|
|
46
|
+
if (!group)
|
|
47
|
+
continue;
|
|
48
|
+
if (typeof group === 'string') {
|
|
49
|
+
if (group === '')
|
|
50
|
+
continue;
|
|
51
|
+
result.push(group === '<THIRD_PARTY_MODULES>'
|
|
52
|
+
? ['^[a-z]', String.raw `^@\w`]
|
|
53
|
+
: [formatSimpleImportRegex(group)]);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (!Array.isArray(group) || group.length === 0)
|
|
57
|
+
continue;
|
|
58
|
+
const groupRegexes = [];
|
|
59
|
+
for (const item of group) {
|
|
60
|
+
if (!item || typeof item !== 'string' || item === '')
|
|
61
|
+
continue;
|
|
62
|
+
if (item === '<THIRD_PARTY_MODULES>') {
|
|
63
|
+
groupRegexes.push('^[a-z]', String.raw `^@\w`);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
groupRegexes.push(formatSimpleImportRegex(item));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (groupRegexes.length > 0) {
|
|
70
|
+
result.push([...new Set(groupRegexes)]);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
export default defineImports;
|
|
76
|
+
//# sourceMappingURL=define-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-imports.js","sources":["../../src/lib/define-imports.ts"],"names":[],"mappings":"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AC,GAAG,CAAA,MAAM,CAAC;gBAC9B,CAAC,CAAC,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CACrC,CAAC;YACF,SAAS;QACX,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QAE1D,MAAM,YAAY,GAAa,EAAE,CAAC;QAElC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE;gBAAE,SAAS;YAE/D,IAAI,IAAI,KAAK,uBAAuB,EAAE,CAAC;gBACrC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAA,MAAM,CAAC,CAAC;YAChD,CAAC;iBAAM,CAAC;gBACN,YAAY,CAAC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QAED,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,qBAAqB,CAAC"}
|