@progressive-victory/eslint-plugin-index-file 0.0.21 → 0.0.22
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enforce-index-usage.d.ts","sourceRoot":"","sources":["../../src/rules/enforce-index-usage.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB;;
|
|
1
|
+
{"version":3,"file":"enforce-index-usage.d.ts","sourceRoot":"","sources":["../../src/rules/enforce-index-usage.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB;;CAuChC,CAAA"}
|
|
@@ -5,8 +5,9 @@ export const enforceIndexUsageRule = createRule({
|
|
|
5
5
|
create(context) {
|
|
6
6
|
return {
|
|
7
7
|
ExportNamedDeclaration(node) {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const filePathStr = path.resolve(context.physicalFilename);
|
|
9
|
+
const filePath = path.parse(filePathStr);
|
|
10
|
+
const cwd = filePath.dir;
|
|
10
11
|
const cwdFiles = fs.readdirSync(cwd);
|
|
11
12
|
const index = cwdFiles.find(x => x === "index.ts");
|
|
12
13
|
if (!index)
|
|
@@ -14,10 +15,8 @@ export const enforceIndexUsageRule = createRule({
|
|
|
14
15
|
messageId: 'noIndexPresent',
|
|
15
16
|
node
|
|
16
17
|
});
|
|
17
|
-
const fileNameArr = context.filename.split('.');
|
|
18
|
-
const fileName = fileNameArr[0];
|
|
19
18
|
const indexContent = fs.readFileSync(path.join(cwd, "index.ts")).toString();
|
|
20
|
-
const regExStr = `export \\* from ['|"]\\.\\/${
|
|
19
|
+
const regExStr = `export \\* from ['|"]\\.\\/${filePath.name}(\\.js|)['|"](;|)`;
|
|
21
20
|
const pattern = new RegExp(regExStr);
|
|
22
21
|
if (!pattern.test(indexContent))
|
|
23
22
|
context.report({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enforce-index-usage.js","sourceRoot":"","sources":["../../src/rules/enforce-index-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAC;IAC5C,MAAM,CAAC,OAAO;QACV,OAAO;YACH,sBAAsB,CAAC,IAAI;gBACvB,MAAM,
|
|
1
|
+
{"version":3,"file":"enforce-index-usage.js","sourceRoot":"","sources":["../../src/rules/enforce-index-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAC;IAC5C,MAAM,CAAC,OAAO;QACV,OAAO;YACH,sBAAsB,CAAC,IAAI;gBACvB,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;gBAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;gBACxC,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAA;gBACxB,MAAM,QAAQ,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;gBACpC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,UAAU,CAAC,CAAA;gBAClD,IAAG,CAAC,KAAK;oBAAE,OAAO,CAAC,MAAM,CAAC;wBAClB,SAAS,EAAE,gBAAgB;wBAC3B,IAAI;qBACP,CAAC,CAAA;gBAEN,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;gBAC3E,MAAM,QAAQ,GAAG,8BAA8B,QAAQ,CAAC,IAAI,mBAAmB,CAAA;gBAC/E,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAA;gBACpC,IAAG,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;oBAAE,OAAO,CAAC,MAAM,CAAC;wBAC3C,SAAS,EAAE,oBAAoB;wBAC/B,IAAI;qBACP,CAAC,CAAA;YACN,CAAC;SACJ,CAAA;IACL,CAAC;IACD,IAAI,EAAE;QACF,IAAI,EAAE;YACF,WAAW,EAAE,gDAAgD;YAC7D,WAAW,EAAE,IAAI;YACjB,oBAAoB,EAAE,KAAK;SAC9B;QACD,QAAQ,EAAE;YACN,kBAAkB,EAAE,uDAAuD;YAC3E,cAAc,EAAE,iDAAiD;SACpE;QACD,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,EAAE;KACb;IACD,IAAI,EAAE,qBAAqB;IAC3B,cAAc,EAAE,EAAE;CACrB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progressive-victory/eslint-plugin-index-file",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "Plugin that enforces the use of index files with eslint.",
|
|
5
5
|
"homepage": "https://github.com/Progressive-Victory/eslint-index-file-plugin#readme",
|
|
6
6
|
"bugs": {
|