support writing aspida api definition
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-aspida
:
$ npm install eslint-plugin-aspida --save-dev
Add aspida
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"aspida"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"aspida/rule-name": 2
}
}
We serve recommended configure. To use it:
{
"extends": [
"plugin:aspida/recommended"
]
}
Make sure whether Methods
exported.
Disallow unused member in each methods.
Disallow using literal or expression as interface key.
Disallow non-property-signature (like below)
interface Methods {
get: {
query: Type; // valid
[key: string]: Type; // invalid
}
}
Disallow old (aspida < 0.14) member name reqData
and resData
Disallow Refer type in each methods.
interface Methods {
get: {
query: Type; // valid
};
post: PostDefinitionType; // invalid
}
Ignoring this rule won't cause error but other rule won't work correctly
Limit reqFormat
type one of these:
ArrayBuffer
Blob
string
FormData
Make sure method name is one of valid HTTP method
- get
- head
- post
- put
- delete
- connect
- options
- trace
- patch
Disallow invalid type like below:
interface Methods {
get;
post: any;
put: {
query;
}
}