eslint-plugin-roro
Advanced tools
Comparing version 0.0.1 to 0.0.2
# Changelog | ||
## [0.0.2](https://github.com/tasshi-me/eslint-plugin-roro/compare/v0.0.1...v0.0.2) (2024-12-08) | ||
### Bug Fixes | ||
* plugin structure ([19ca6ff](https://github.com/tasshi-me/eslint-plugin-roro/commit/19ca6ffb7752d595a0bbde379bca55a384e4f9a3)) | ||
### Documentation | ||
* create rules pages ([5340ae7](https://github.com/tasshi-me/eslint-plugin-roro/commit/5340ae75b77f8f47a96fae9dc7410e1f00f7e6c2)) | ||
## 0.0.1 (2024-12-08) | ||
@@ -4,0 +16,0 @@ |
declare const plugin: { | ||
meta: { | ||
name: string; | ||
version: string; | ||
}; | ||
rules: { | ||
"receive-object": import("eslint").Rule.RuleModule; | ||
"return-object": import("eslint").Rule.RuleModule; | ||
}; | ||
} & { | ||
configs: { | ||
readonly recommended: { | ||
recommended: { | ||
files: string[]; | ||
plugins: { | ||
"example-typed-linting": /*elided*/ any; | ||
"eslint-plugin-roro": { | ||
meta: { | ||
name: string; | ||
version: string; | ||
}; | ||
rules: { | ||
"receive-object": import("eslint").Rule.RuleModule; | ||
"return-object": import("eslint").Rule.RuleModule; | ||
}; | ||
}; | ||
}; | ||
languageOptions: { | ||
parserOptions: { | ||
projectService: boolean; | ||
tsconfigRootDir: string; | ||
}; | ||
}; | ||
rules: { | ||
"receive-object": import("@typescript-eslint/utils/ts-eslint").RuleModule<"shouldReceiveObject" | "shouldReceiveSingleParameter", [], import("./utils/create-rule.js").PluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"return-object": import("@typescript-eslint/utils/ts-eslint").RuleModule<"shouldReturnObject", [], import("./utils/create-rule.js").PluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"eslint-plugin-roro/receive-object": "error"; | ||
"eslint-plugin-roro/return-object": "error"; | ||
}; | ||
}; | ||
}; | ||
meta: { | ||
name: string; | ||
version: string; | ||
}; | ||
rules: { | ||
"receive-object": import("@typescript-eslint/utils/ts-eslint").RuleModule<"shouldReceiveObject" | "shouldReceiveSingleParameter", [], import("./utils/create-rule.js").PluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"return-object": import("@typescript-eslint/utils/ts-eslint").RuleModule<"shouldReturnObject", [], import("./utils/create-rule.js").PluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
}; | ||
}; | ||
export default plugin; | ||
//# sourceMappingURL=index.d.ts.map |
import { rules } from "./rules/index.js"; | ||
const { name, version } = require("../package.json"); | ||
const plugin = { | ||
configs: { | ||
get recommended() { | ||
return recommended; | ||
}, | ||
}, | ||
import module from "node:module"; | ||
const require = module.createRequire(import.meta.url); | ||
const name = "eslint-plugin-roro"; | ||
const { version } = require("../package.json"); | ||
const base = { | ||
meta: { name, version }, | ||
rules, | ||
}; | ||
const recommended = { | ||
plugins: { | ||
"example-typed-linting": plugin, | ||
const configs = { | ||
recommended: { | ||
files: ["**/*.{ts,cts,mts,jsx,tsx}"], | ||
plugins: { | ||
[name]: base, | ||
}, | ||
languageOptions: { | ||
parserOptions: { | ||
projectService: true, | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
rules: { | ||
[`${name}/receive-object`]: "error", | ||
[`${name}/return-object`]: "error", | ||
}, | ||
}, | ||
rules, | ||
}; | ||
const plugin = Object.assign(base, { configs }); | ||
export default plugin; |
@@ -0,5 +1,6 @@ | ||
import { Rule } from "eslint"; | ||
export declare const rules: { | ||
"receive-object": import("@typescript-eslint/utils/ts-eslint").RuleModule<"shouldReceiveObject" | "shouldReceiveSingleParameter", [], import("../utils/create-rule.js").PluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"return-object": import("@typescript-eslint/utils/ts-eslint").RuleModule<"shouldReturnObject", [], import("../utils/create-rule.js").PluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"receive-object": Rule.RuleModule; | ||
"return-object": Rule.RuleModule; | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
import { ESLintUtils } from "@typescript-eslint/utils"; | ||
const { RuleCreator: ruleCreator } = ESLintUtils; | ||
export const createRule = ruleCreator((name) => `https://github.com/tasshi-me/eslint-plugin-roro/#${name}`); | ||
export const createRule = ruleCreator((name) => `https://github.com/tasshi-me/eslint-plugin-roro/tree/main/eslint-plugin-example-typed-linting/docs/${name}.md`); |
{ | ||
"name": "eslint-plugin-roro", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "An ESLint plugin to follow the RORO (Receive an Object, Return an Object) pattern.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -7,3 +7,3 @@ # eslint-plugin-roro | ||
> This plugin provide a rule to enforce the [RORO](https://medium.com/free-code-camp/elegant-patterns-in-modern-javascript-roro-be01e7669cbd) (An ESLint plugin to follow the RORO (Receive an Object, Return an Object) pattern.) | ||
> This plugin provide rules to enforce the [RORO](https://medium.com/free-code-camp/elegant-patterns-in-modern-javascript-roro-be01e7669cbd) (Receive an Object, Return an Object) pattern. | ||
@@ -16,49 +16,18 @@ ## Usage | ||
## Rules | ||
```javascript | ||
// eslint.config.mjs | ||
import eslintPluginRORO from "eslint-plugin-roro"; | ||
- [receive-object](#receive-object) | ||
- [return-object](#return-object) | ||
### receive-object | ||
Enforce functions to receive only a single object. | ||
#### ❌Incorrect | ||
```typescript | ||
const func = (param1: string, param2: string) => { | ||
/* ... */ | ||
}; | ||
export default [eslintPluginRORO.configs.recommended]; | ||
``` | ||
#### ✅Correct | ||
## Rules | ||
```typescript | ||
const func = (params: { param1: string; param2: string }) => { | ||
/* ... */ | ||
}; | ||
``` | ||
| Name | Description | | ||
| --------------------------------------------- | -------------------------------------------------- | | ||
| [receive-object](./docs/rules/receive-object) | Enforce functions to receive only a single object. | | ||
| [return-object](./docs/rules/return-object) | Enforce functions to return an object. | | ||
### return-object | ||
Enforce functions to return an object. | ||
#### ❌Incorrect | ||
```typescript | ||
const func = (): string => { | ||
/* ... */ | ||
}; | ||
``` | ||
#### ✅Correct | ||
```typescript | ||
const func = (): { value: string } => { | ||
/* ... */ | ||
}; | ||
``` | ||
## License | ||
[MIT](./LICENSE) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
18319
302
32