mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 04:52:26 -05:00
chore: add more lint rules
This commit is contained in:
parent
f3745f95f4
commit
46766438f8
4 changed files with 80 additions and 0 deletions
23
fo.json
Normal file
23
fo.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"lint": {
|
||||
"plugins2": ["npm:foo"],
|
||||
"rules": {
|
||||
"exclude": [
|
||||
"ban-ts-comment",
|
||||
"prefix/whatever"
|
||||
]
|
||||
},
|
||||
"plugins": {
|
||||
"foo/bar": {
|
||||
"url": "./foo.js",
|
||||
"rules": {
|
||||
"exclude": {}
|
||||
}
|
||||
},
|
||||
"specifier": "npm:foo/url",
|
||||
"rules": {
|
||||
"exclude": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
foo.js
3
foo.js
|
@ -9,3 +9,6 @@ Vue.component("todo-item", {
|
|||
Vue.component("Todo", {
|
||||
// ...
|
||||
});
|
||||
|
||||
describe("foo", () => {});
|
||||
describe("foo", () => {});
|
||||
|
|
9
foo.tsx
Normal file
9
foo.tsx
Normal file
|
@ -0,0 +1,9 @@
|
|||
const a = <div style={{}} />;
|
||||
const b = <div style="foo" />;
|
||||
const c: Foo<number> = {
|
||||
node: 2,
|
||||
};
|
||||
|
||||
interface Foo<T> {
|
||||
node: T;
|
||||
}
|
45
plugin.js
45
plugin.js
|
@ -65,6 +65,51 @@ export default {
|
|||
name: PLUGIN_NAME,
|
||||
rules: {
|
||||
[RULE1_NAME]: rule,
|
||||
"jsx-style-string": {
|
||||
create(context) {
|
||||
return {
|
||||
VariableDeclaration(node) {
|
||||
console.log("INTERFAcE", { ...node, parent: null });
|
||||
},
|
||||
JSXAttribute(node) {
|
||||
if (
|
||||
node.name.type === "Identifier" && node.name.value === "style" &&
|
||||
node.value.type !== "StringLiteral"
|
||||
) {
|
||||
context.report({
|
||||
node: node.value,
|
||||
message: "Use a string literal for 'style'",
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
"jest/no-identical-title": {
|
||||
create(context) {
|
||||
console.log(context.source());
|
||||
const seen = new Set();
|
||||
return {
|
||||
CallExpression(node) {
|
||||
if (
|
||||
node.callee.type === "Identifier" &&
|
||||
node.callee.value === "describe" && node.arguments.length > 0 &&
|
||||
node.arguments[0].expression.type === "StringLiteral"
|
||||
) {
|
||||
const name = node.arguments[0].expression.value;
|
||||
if (seen.has(name)) {
|
||||
context.report({
|
||||
node,
|
||||
message: `Duplicate describe title found`,
|
||||
});
|
||||
}
|
||||
|
||||
seen.add(name);
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
"vue/multi-word-component-names": {
|
||||
create(context) {
|
||||
return {
|
||||
|
|
Loading…
Add table
Reference in a new issue