@akinon/eslint-plugin-projectzero 1.14.1 → 1.15.0
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/.gitattributes +15 -0
- package/CHANGELOG.md +6 -0
- package/dist/rules/router-import.js +37 -37
- package/dist/rules/urls-without-slash.js +40 -40
- package/package.json +1 -1
package/.gitattributes
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
*.js text eol=lf
|
|
2
|
+
*.jsx text eol=lf
|
|
3
|
+
*.ts text eol=lf
|
|
4
|
+
*.tsx text eol=lf
|
|
5
|
+
*.json text eol=lf
|
|
6
|
+
*.md text eol=lf
|
|
7
|
+
|
|
8
|
+
.eslintignore text eol=lf
|
|
9
|
+
.eslintrc text eol=lf
|
|
10
|
+
.gitignore text eol=lf
|
|
11
|
+
.prettierrc text eol=lf
|
|
12
|
+
.yarnrc text eol=lf
|
|
13
|
+
|
|
14
|
+
* text=auto
|
|
15
|
+
|
package/CHANGELOG.md
CHANGED
|
@@ -1,37 +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/hooks/use-router.ts')) {
|
|
7
|
-
return {};
|
|
8
|
-
}
|
|
9
|
-
return {
|
|
10
|
-
ImportDeclaration(node) {
|
|
11
|
-
if (node.source.value === 'next/router' || node.source.value === 'next/navigation' && node.specifiers.find((s) => s.local.name === 'useRouter')) {
|
|
12
|
-
context.report({
|
|
13
|
-
messageId: 'routerImport',
|
|
14
|
-
node,
|
|
15
|
-
fix: (fixer) => {
|
|
16
|
-
if (node.specifiers.find((s) => s.type === 'ImportSpecifier')) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return fixer.replaceText(node, node.specifiers
|
|
20
|
-
.map((specifier) => `import { ${specifier.local.name} } from '@akinon/next/hooks';`)
|
|
21
|
-
.join('\n'));
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
meta: {
|
|
29
|
-
messages: {
|
|
30
|
-
routerImport: "Import 'useRouter' hooks from '@akinon/next/hooks'."
|
|
31
|
-
},
|
|
32
|
-
type: 'problem',
|
|
33
|
-
fixable: 'code',
|
|
34
|
-
schema: []
|
|
35
|
-
},
|
|
36
|
-
defaultOptions: []
|
|
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/hooks/use-router.ts')) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
ImportDeclaration(node) {
|
|
11
|
+
if (node.source.value === 'next/router' || node.source.value === 'next/navigation' && node.specifiers.find((s) => s.local.name === 'useRouter')) {
|
|
12
|
+
context.report({
|
|
13
|
+
messageId: 'routerImport',
|
|
14
|
+
node,
|
|
15
|
+
fix: (fixer) => {
|
|
16
|
+
if (node.specifiers.find((s) => s.type === 'ImportSpecifier')) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return fixer.replaceText(node, node.specifiers
|
|
20
|
+
.map((specifier) => `import { ${specifier.local.name} } from '@akinon/next/hooks';`)
|
|
21
|
+
.join('\n'));
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
meta: {
|
|
29
|
+
messages: {
|
|
30
|
+
routerImport: "Import 'useRouter' hooks from '@akinon/next/hooks'."
|
|
31
|
+
},
|
|
32
|
+
type: 'problem',
|
|
33
|
+
fixable: 'code',
|
|
34
|
+
schema: []
|
|
35
|
+
},
|
|
36
|
+
defaultOptions: []
|
|
37
|
+
});
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("@typescript-eslint/utils");
|
|
4
|
-
const URLS = [
|
|
5
|
-
'/users/logout/'
|
|
6
|
-
];
|
|
7
|
-
exports.default = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
8
|
-
create(context) {
|
|
9
|
-
if (!context.getFilename().includes('urls.ts')) {
|
|
10
|
-
return {};
|
|
11
|
-
}
|
|
12
|
-
return {
|
|
13
|
-
Literal(node) {
|
|
14
|
-
var _a;
|
|
15
|
-
const value = (_a = node.value) === null || _a === void 0 ? void 0 : _a.toString();
|
|
16
|
-
if (!value) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
URLS.map((url) => {
|
|
20
|
-
if (value.endsWith(url)) {
|
|
21
|
-
context.report({
|
|
22
|
-
messageId: 'UrlWithoutSlash',
|
|
23
|
-
node,
|
|
24
|
-
fix: (fixer) => fixer.replaceText(node, `\`${value.slice(0, -1)}\``)
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
meta: {
|
|
32
|
-
messages: {
|
|
33
|
-
UrlWithoutSlash: 'It must not end with a forward slash (/).'
|
|
34
|
-
},
|
|
35
|
-
type: 'problem',
|
|
36
|
-
fixable: 'code',
|
|
37
|
-
schema: []
|
|
38
|
-
},
|
|
39
|
-
defaultOptions: []
|
|
40
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
4
|
+
const URLS = [
|
|
5
|
+
'/users/logout/'
|
|
6
|
+
];
|
|
7
|
+
exports.default = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
8
|
+
create(context) {
|
|
9
|
+
if (!context.getFilename().includes('urls.ts')) {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
Literal(node) {
|
|
14
|
+
var _a;
|
|
15
|
+
const value = (_a = node.value) === null || _a === void 0 ? void 0 : _a.toString();
|
|
16
|
+
if (!value) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
URLS.map((url) => {
|
|
20
|
+
if (value.endsWith(url)) {
|
|
21
|
+
context.report({
|
|
22
|
+
messageId: 'UrlWithoutSlash',
|
|
23
|
+
node,
|
|
24
|
+
fix: (fixer) => fixer.replaceText(node, `\`${value.slice(0, -1)}\``)
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
meta: {
|
|
32
|
+
messages: {
|
|
33
|
+
UrlWithoutSlash: 'It must not end with a forward slash (/).'
|
|
34
|
+
},
|
|
35
|
+
type: 'problem',
|
|
36
|
+
fixable: 'code',
|
|
37
|
+
schema: []
|
|
38
|
+
},
|
|
39
|
+
defaultOptions: []
|
|
40
|
+
});
|