@akinon/eslint-plugin-projectzero 1.23.0-rc.0 → 1.23.0-rc.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/CHANGELOG.md +8 -0
- package/configs/core.ts +1 -0
- package/dist/configs/core.js +1 -0
- package/dist/rules/index.js +3 -1
- package/dist/rules/invalid-imports.js +37 -0
- package/package.json +1 -1
- package/rules/index.ts +3 -1
- package/rules/invalid-imports.ts +43 -0
package/CHANGELOG.md
CHANGED
package/configs/core.ts
CHANGED
package/dist/configs/core.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.default = {
|
|
|
10
10
|
'@akinon/projectzero/check-locale': 'error',
|
|
11
11
|
'@akinon/projectzero/meta-data-import': 'error',
|
|
12
12
|
'@akinon/projectzero/urls-without-slash': 'error',
|
|
13
|
+
'@akinon/projectzero/invalid-imports': 'error',
|
|
13
14
|
'no-restricted-syntax': [
|
|
14
15
|
'error',
|
|
15
16
|
{
|
package/dist/rules/index.js
CHANGED
|
@@ -13,6 +13,7 @@ const check_locale_1 = __importDefault(require("./check-locale"));
|
|
|
13
13
|
const meta_data_import_1 = __importDefault(require("./meta-data-import"));
|
|
14
14
|
const check_middleware_order_1 = __importDefault(require("./check-middleware-order"));
|
|
15
15
|
const urls_without_slash_1 = __importDefault(require("./urls-without-slash"));
|
|
16
|
+
const invalid_imports_1 = __importDefault(require("./invalid-imports"));
|
|
16
17
|
const rules = {
|
|
17
18
|
'client-url': client_url_1.default,
|
|
18
19
|
'image-import': image_import_1.default,
|
|
@@ -22,6 +23,7 @@ const rules = {
|
|
|
22
23
|
'check-locale': check_locale_1.default,
|
|
23
24
|
'meta-data-import': meta_data_import_1.default,
|
|
24
25
|
'check-middleware-order': check_middleware_order_1.default,
|
|
25
|
-
'urls-without-slash': urls_without_slash_1.default
|
|
26
|
+
'urls-without-slash': urls_without_slash_1.default,
|
|
27
|
+
'invalid-imports': invalid_imports_1.default
|
|
26
28
|
};
|
|
27
29
|
exports.rules = rules;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
4
|
+
exports.default = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
5
|
+
create(context) {
|
|
6
|
+
if (!context.getFilename().includes('akinon-next')) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
ImportDeclaration(node) {
|
|
11
|
+
const invalidImports = ['@theme', 'projectzeronext'];
|
|
12
|
+
const importsFromInvalidSources = node.source.value &&
|
|
13
|
+
invalidImports.some((invalidImport) => node.source.value.includes(invalidImport));
|
|
14
|
+
if (importsFromInvalidSources) {
|
|
15
|
+
node.specifiers.forEach((specifier) => {
|
|
16
|
+
context.report({
|
|
17
|
+
messageId: 'invalidImport',
|
|
18
|
+
node: specifier,
|
|
19
|
+
data: {
|
|
20
|
+
importName: specifier.local.name
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
meta: {
|
|
29
|
+
type: 'problem',
|
|
30
|
+
fixable: 'code',
|
|
31
|
+
messages: {
|
|
32
|
+
invalidImport: "Invalid import statement: '{{importName}}' should not be imported from '@Theme' or 'projectzeronext'."
|
|
33
|
+
},
|
|
34
|
+
schema: []
|
|
35
|
+
},
|
|
36
|
+
defaultOptions: []
|
|
37
|
+
});
|
package/package.json
CHANGED
package/rules/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import checkLocale from './check-locale';
|
|
|
7
7
|
import metaDataImport from './meta-data-import';
|
|
8
8
|
import checkMiddlewareOrder from './check-middleware-order';
|
|
9
9
|
import urlsWithoutSlash from './urls-without-slash';
|
|
10
|
+
import invalidImports from './invalid-imports';
|
|
10
11
|
|
|
11
12
|
const rules = {
|
|
12
13
|
'client-url': clientUrl,
|
|
@@ -17,7 +18,8 @@ const rules = {
|
|
|
17
18
|
'check-locale': checkLocale,
|
|
18
19
|
'meta-data-import': metaDataImport,
|
|
19
20
|
'check-middleware-order': checkMiddlewareOrder,
|
|
20
|
-
'urls-without-slash': urlsWithoutSlash
|
|
21
|
+
'urls-without-slash': urlsWithoutSlash,
|
|
22
|
+
'invalid-imports': invalidImports
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
export { rules };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
|
|
3
|
+
export default ESLintUtils.RuleCreator.withoutDocs({
|
|
4
|
+
create(context) {
|
|
5
|
+
if (!context.getFilename().includes('akinon-next')) {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
ImportDeclaration(node) {
|
|
11
|
+
const invalidImports = ['@theme', 'projectzeronext'];
|
|
12
|
+
|
|
13
|
+
const importsFromInvalidSources =
|
|
14
|
+
node.source.value &&
|
|
15
|
+
invalidImports.some((invalidImport) =>
|
|
16
|
+
node.source.value.includes(invalidImport)
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
if (importsFromInvalidSources) {
|
|
20
|
+
node.specifiers.forEach((specifier) => {
|
|
21
|
+
context.report({
|
|
22
|
+
messageId: 'invalidImport',
|
|
23
|
+
node: specifier,
|
|
24
|
+
data: {
|
|
25
|
+
importName: specifier.local.name
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
meta: {
|
|
34
|
+
type: 'problem',
|
|
35
|
+
fixable: 'code',
|
|
36
|
+
messages: {
|
|
37
|
+
invalidImport:
|
|
38
|
+
"Invalid import statement: '{{importName}}' should not be imported from '@Theme' or 'projectzeronext'."
|
|
39
|
+
},
|
|
40
|
+
schema: []
|
|
41
|
+
},
|
|
42
|
+
defaultOptions: []
|
|
43
|
+
});
|