@alien_intelligence/eslint-plugin-nitpicker 0.7.0 → 0.7.1
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/README.md +6 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,12 +107,12 @@ Shipped by the `react` config (and `all`).
|
|
|
107
107
|
|
|
108
108
|
### AdonisJS rules
|
|
109
109
|
Shipped by the `adonisjs` config (and `all`).
|
|
110
|
-
| Rule
|
|
111
|
-
|
|
112
|
-
| `nitpicker/migration-table-order`
|
|
113
|
-
| `nitpicker/require-controller-jsdoc
|
|
114
|
-
| `nitpicker/require-migration-jsdoc`
|
|
115
|
-
| `nitpicker/require-validated-request
|
|
110
|
+
| Rule | Fixable | Description |
|
|
111
|
+
|---------------------------------------|---------|-----------------------------------------------------------------------------------------------------------------|
|
|
112
|
+
| `nitpicker/migration-table-order` | | Group migration table statements as columns, then timestamps, then indexes. |
|
|
113
|
+
| `nitpicker/require-controller-jsdoc` | | Require a JSDoc comment describing an AdonisJS controller (`*Controller` class). |
|
|
114
|
+
| `nitpicker/require-migration-jsdoc` | | Require a JSDoc comment describing an AdonisJS migration. |
|
|
115
|
+
| `nitpicker/require-validated-request` | | Require request data through `request.validateUsing()`, not raw `request.input/body/qs/all` (`allowIn` option). |
|
|
116
116
|
|
|
117
117
|
¹ Only the terminal-period case is auto-fixed; a mid-comment sentence break is reported without a fix so wrapped prose is never mangled.
|
|
118
118
|
² Auto-fixed only when the object holds no comments; an object with an inline comment is reported without a fix so the comment is never dropped.
|
package/dist/index.js
CHANGED
|
@@ -9,5 +9,5 @@ ${r} */`;return s.replaceTextRange(i.range,a)}});}}}}},et=new ee;var te=class ex
|
|
|
9
9
|
${e.properties.map(m=>`${r}${t.getText(m)}`).join(`,
|
|
10
10
|
`)},
|
|
11
11
|
${s}}`}var ae=class extends l{name="require-multiline-object";defaultOptions=[{maxKeys:o.OBJECTS.MAX_INLINE_KEYS,indent:o.OBJECTS.INDENT_WIDTH}];meta={type:"suggestion",fixable:"code",docs:{description:"Require an object literal with more than a few properties to span multiple lines.",recommended:true,category:"base"},schema:[{type:"object",properties:{maxKeys:{type:"integer",minimum:1},indent:{type:"integer",minimum:1}},additionalProperties:false}],messages:{shouldWrap:p({problem:"This object literal has {{count}} properties packed onto a single line.",why:"An object with more than {{max}} properties is easier to scan, diff, and edit when each property sits on its own line",fix:"Break it across multiple lines, one property per line with a trailing comma"})}};create(e,i){let n=i[0]?.maxKeys??o.OBJECTS.MAX_INLINE_KEYS,s=i[0]?.indent??o.OBJECTS.INDENT_WIDTH;return {ObjectExpression(r){if(r.properties.length<=n||r.loc.start.line!==r.loc.end.line)return;let a=e.sourceCode.getCommentsInside(r).length>0;e.report({node:r,messageId:"shouldWrap",data:{count:r.properties.length,max:n},fix:a?null:m=>m.replaceText(r,ct(e.sourceCode,r,s))});}}}},ut=new ae;var le=class extends l{name="no-jsx-comments";defaultOptions=[];meta={type:"suggestion",docs:{description:"Disallow inline `{/* ... */}` comments inside JSX.",recommended:true,category:"react"},schema:[],messages:{jsxComment:p({problem:"This JSX holds an inline `{/* ... */}` comment.",why:"A comment labeling a JSX section is a sign it should be its own named component, JSX should read as structure, not carry prose markers",fix:"Extract the section into a named sub-component whose name says what the comment said, or drop the comment"})}};create(e){return {JSXExpressionContainer(i){i.expression.type==="JSXEmptyExpression"&&e.sourceCode.getCommentsInside(i).length!==0&&e.report({node:i,messageId:"jsxComment"});}}}},mt=new le;var pe=class extends l{name="require-context-hook-destructure";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require the result of a context-consumer hook to be destructured.",recommended:true,category:"react"},schema:[],messages:{destructure:p({problem:"`{{hook}}` is bound whole instead of destructured.",why:"Destructuring at the call site names exactly what the caller uses and reads better than repeated `{{name}}.member` access",fix:"Destructure the members in use, e.g. `const { a, b } = {{hook}}()`"})}};create(e){return {VariableDeclarator(i){i.id.type!=="Identifier"||i.init?.type!=="CallExpression"||i.init.callee.type!=="Identifier"||!st(i.init.callee.name)||e.report({node:i,messageId:"destructure",data:{hook:i.init.callee.name,name:i.id.name}});}}}},dt=new pe;var ce=class extends l{name="require-derived-usememo";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require a derived value in a component or hook to be memoized with useMemo.",recommended:true,category:"react"},schema:[],messages:{useMemo:p({problem:"This derived value is computed inline on every render.",why:"A value derived through a call is recomputed each render and has nowhere to document itself, a useMemo makes it stable and gives it a JSDoc home",fix:"Wrap it in `useMemo(() => ..., [deps])` with a JSDoc describing the value, even for a one-liner"})}};create(e){return {VariableDeclarator(i){if(i.parent.type!=="VariableDeclaration"||i.parent.kind!=="const"||i.id.type!=="Identifier"||i.init===null)return;let n=Be(i);n===null||!ot(n,e.sourceCode.visitorKeys)||lt(i.init,e.sourceCode.visitorKeys)&&e.report({node:i,messageId:"useMemo"});}}}},ft=new ce;var ue=class extends l{name="require-hook-object-return";defaultOptions=[];meta={type:"suggestion",fixable:"code",docs:{description:"Require a custom hook to return an object rather than a bare function.",recommended:true,category:"react"},schema:[],messages:{wrapInObject:p({problem:"This hook returns a bare function instead of an object.",why:"Returning an object lets the hook expose new members later without changing every call site, a bare function locks its shape",fix:"Return the function inside an object, e.g. `return { handleThing }`"})}};create(e){let i=r=>{if(ne(r))return true;if(r.type!=="Identifier")return false;let m=ASTUtils.findVariable(e.sourceCode.getScope(r),r.name)?.defs.at(-1)?.node;return m?.type==="VariableDeclarator"&&ne(m.init)},n=r=>{e.report({node:r,messageId:"wrapInObject",fix:r.type==="Identifier"?a=>a.replaceText(r,`{ ${r.name} }`):void 0});},s=r=>{let a=T(r);if(!(a===void 0||!D(a))){if(r.type==="ArrowFunctionExpression"&&r.body.type!=="BlockStatement"){i(r.body)&&n(r.body);return}b(r.body,e.sourceCode.visitorKeys,m=>(m!==null&&i(m)&&n(m),false));}};return {FunctionDeclaration(r){s(r);},FunctionExpression(r){s(r);},ArrowFunctionExpression(r){s(r);}}}},gt=new ue;var me=class extends l{name="require-memo-callback-jsdoc";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require a JSDoc on a useMemo or useCallback (with an `@param` per useCallback parameter).",recommended:true,category:"react"},schema:[],messages:{missingJSDoc:p({problem:"This `{{hook}}` has no JSDoc.",why:"A memoized value or handler should document what it is, so its purpose is clear without reading the factory",fix:"Add a `/** ... */` JSDoc above the `const`"}),missingParam:p({problem:"This `useCallback`'s JSDoc documents fewer parameters than the callback takes.",why:"A callback is a function, so each parameter it takes should be documented like any other",fix:"Add an `@param` line for each parameter of the callback"})}};create(e){return {VariableDeclarator(i){if(i.init?.type!=="CallExpression"||i.init.callee.type!=="Identifier"||!o.REACT.MEMO_HOOKS.has(i.init.callee.name))return;let n=i.parent;if(n.parent?.type==="ExportNamedDeclaration"&&(n=n.parent),!y(e.sourceCode,n)){e.report({node:i.id,messageId:"missingJSDoc",data:{hook:i.init.callee.name}});return}if(i.init.callee.name!=="useCallback")return;let s=i.init.arguments[0];if(s?.type!=="ArrowFunctionExpression"&&s?.type!=="FunctionExpression"||s.params.length===0)return;(e.sourceCode.getCommentsBefore(n).at(-1)?.value.split(`
|
|
12
|
-
`)??[]).filter(m=>O(m)==="param").length<s.params.length&&e.report({node:i.id,messageId:"missingParam"});}}}},yt=new me;var jt=[he,xe,Re,Oe,Ie,Le,we,ze,je,Pe,_e,Je,Ve,He,Xe,Ye,Ze,Qe,et,tt,nt,pt,ut,mt,dt,ft,gt,yt],R=Object.fromEntries(jt.map(t=>[t.name,t.toRuleModule()]));function E(t){let e={};for(let[i,n]of Object.entries(R))(n.meta.docs?.category??"base")===t&&(e[`${o.PLUGIN_NAME}/${i}`]="warn");return e}function St(){let t={};for(let e of Object.keys(R))t[`${o.PLUGIN_NAME}/${e}`]="warn";return t}function ht(t){return {name:`${o.PLUGIN_NAME}/all`,plugins:{[o.PLUGIN_NAME]:t},settings:{[o.PLUGIN_NAME]:{adonisjs:true,react:true}},rules:St()}}function w(t){return {name:`${o.PLUGIN_NAME}/base`,plugins:{[o.PLUGIN_NAME]:t},rules:E("base")}}function Tt(t){return {...w(t),name:`${o.PLUGIN_NAME}/recommended`}}var Pt=["**/start/routes.ts","**/start/routes/**/*.ts"];function bt(t){return {name:`${o.PLUGIN_NAME}/adonisjs`,plugins:{[o.PLUGIN_NAME]:t},settings:{[o.PLUGIN_NAME]:{adonisjs:true}},rules:{...E("adonisjs"),[`${o.PLUGIN_NAME}/no-decorative-comment-separators`]:["warn",{allowIn:Pt}]}}}function Et(t){return {name:`${o.PLUGIN_NAME}/react`,plugins:{[o.PLUGIN_NAME]:t},settings:{[o.PLUGIN_NAME]:{react:true}},rules:E("react")}}function xt(t){return {base:w(t),recommended:Tt(t),adonisjs:bt(t),react:Et(t),all:ht(t)}}var Rt="0.7.
|
|
12
|
+
`)??[]).filter(m=>O(m)==="param").length<s.params.length&&e.report({node:i.id,messageId:"missingParam"});}}}},yt=new me;var jt=[he,xe,Re,Oe,Ie,Le,we,ze,je,Pe,_e,Je,Ve,He,Xe,Ye,Ze,Qe,et,tt,nt,pt,ut,mt,dt,ft,gt,yt],R=Object.fromEntries(jt.map(t=>[t.name,t.toRuleModule()]));function E(t){let e={};for(let[i,n]of Object.entries(R))(n.meta.docs?.category??"base")===t&&(e[`${o.PLUGIN_NAME}/${i}`]="warn");return e}function St(){let t={};for(let e of Object.keys(R))t[`${o.PLUGIN_NAME}/${e}`]="warn";return t}function ht(t){return {name:`${o.PLUGIN_NAME}/all`,plugins:{[o.PLUGIN_NAME]:t},settings:{[o.PLUGIN_NAME]:{adonisjs:true,react:true}},rules:St()}}function w(t){return {name:`${o.PLUGIN_NAME}/base`,plugins:{[o.PLUGIN_NAME]:t},rules:E("base")}}function Tt(t){return {...w(t),name:`${o.PLUGIN_NAME}/recommended`}}var Pt=["**/start/routes.ts","**/start/routes/**/*.ts"];function bt(t){return {name:`${o.PLUGIN_NAME}/adonisjs`,plugins:{[o.PLUGIN_NAME]:t},settings:{[o.PLUGIN_NAME]:{adonisjs:true}},rules:{...E("adonisjs"),[`${o.PLUGIN_NAME}/no-decorative-comment-separators`]:["warn",{allowIn:Pt}]}}}function Et(t){return {name:`${o.PLUGIN_NAME}/react`,plugins:{[o.PLUGIN_NAME]:t},settings:{[o.PLUGIN_NAME]:{react:true}},rules:E("react")}}function xt(t){return {base:w(t),recommended:Tt(t),adonisjs:bt(t),react:Et(t),all:ht(t)}}var Rt="0.7.1";var de={meta:{name:`eslint-plugin-${o.PLUGIN_NAME}`,version:Rt},rules:R,configs:{}};de.configs=xt(de);var Go=de;export{Go as default};//# sourceMappingURL=index.js.map
|
|
13
13
|
//# sourceMappingURL=index.js.map
|