Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Rule schemas for validation. (#252)
* chore: Test rule schemas. * chore: Add misconfiguration tests for the "type-id-match" rule. * chore: Add misconfiguration tests for the "require-valid-file-annotation" rule. And fix the schema accordingly. * refactor: Specify enum types in rule schemas. * chore: Create a schema for the "boolean-style" rule. * refactor: Export the schema for the "define-flow-type" rule. * chore: Create a schema for the "delimiter-dangle" rule. * chore: Create a schema for the "generic-spacing" rule. * chore: Create a schema for the "no-dupe-keys" rule. * chore: Create a schema for the "no-primitive-constructor-types" rule. * chore: Create a schema for the "no-types-missing-file-annotation" rule. * chore: Create a schema for the "no-weak-types" rule. * chore: Create a schema for the "require-parameter-type" rule. * chore: Create a schema for the "require-return-type" rule. * chore: Create a schema for the "require-variable-type" rule. * chore: Create a schema for the "semi" rule. * chore: Create a schema for the "sort-keys" rule. * chore: Create a schema for the "space-after-type-colon" rule. * chore: Create a schema for the "space-before-generic-bracket" rule. * chore: Create a schema for the "space-before-type-colon" rule. * chore: Create a schema for the "union-intersection-spacing" rule. * refactor: Export the schema for the "use-flow-type" rule. * chore: Create a schema for the "valid-syntax" rule. * fix: Don't decorate the "no-types-missing-file-annotation" rule. * refactor: Use ajv instead of is-my-json-valid. * refactor: Sort rules by name.
- Loading branch information
1 parent
996acd3
commit b1409e3
Showing
42 changed files
with
1,358 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
import _ from 'lodash'; | ||
|
||
export default { | ||
create: (context) => { | ||
return { | ||
GenericTypeAnnotation: (node) => { | ||
const name = _.get(node, 'id.name'); | ||
const schema = []; | ||
|
||
const create = (context) => { | ||
return { | ||
GenericTypeAnnotation: (node) => { | ||
const name = _.get(node, 'id.name'); | ||
|
||
if (RegExp(/^(Boolean|Number|String)$/).test(name)) { | ||
context.report({ | ||
data: { | ||
name | ||
}, | ||
loc: node.loc, | ||
message: 'Unexpected use of {{name}} constructor type.', | ||
node | ||
}); | ||
} | ||
if (RegExp(/^(Boolean|Number|String)$/).test(name)) { | ||
context.report({ | ||
data: { | ||
name | ||
}, | ||
loc: node.loc, | ||
message: 'Unexpected use of {{name}} constructor type.', | ||
node | ||
}); | ||
} | ||
}; | ||
}, | ||
meta: {}, | ||
schema: {} | ||
} | ||
}; | ||
}; | ||
|
||
export default { | ||
create, | ||
schema | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.