Skip to content

Commit

Permalink
fix(camelcase): updated docs, see denoland#1187
Browse files Browse the repository at this point in the history
  • Loading branch information
c-antin committed Sep 15, 2024
1 parent 103c517 commit fd6d40b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/rules/camelcase.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ Of note:
let first_name = "Ichigo";
const obj1 = { last_name: "Hoshimiya" };
const obj2 = { first_name };
const { last_name } = obj1;

function do_something() {}
function foo({ snake_case = "default value" }) {}

class snake_case_class {}
class Also_Not_Valid_Class {}

import { not_camelCased } from "external-module.js";
export * as not_camelCased from "mod.ts";

enum snake_case_enum {
Expand All @@ -50,6 +48,7 @@ const __myPrivateVariable = "Hoshimiya";
const myPrivateVariable_ = "Hoshimiya";
const obj1 = { "last_name": "Hoshimiya" }; // if an object key is wrapped in quotation mark, then it's valid
const obj2 = { "first_name": first_name };
const { last_name } = obj1; // valid, because one has no control over the identifier
const { last_name: lastName } = obj;

function doSomething() {} // function declarations must be camelCase but...
Expand All @@ -58,6 +57,7 @@ function foo({ snake_case: camelCase = "default value" }) {}

class PascalCaseClass {}

import { not_camelCased } from "external-module.js"; // valid, because one has no control over the identifier
import { not_camelCased as camelCased } from "external-module.js";
export * as camelCased from "mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion www/static/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
{
"code": "camelcase",
"docs": "Enforces the use of camelCase in variable names\n\nConsistency in a code base is key for readability and maintainability. This rule\nenforces variable declarations and object property names which you create to be\nin camelCase.\n\nOf note:\n\n- `_` is allowed at the start or end of a variable\n- All uppercase variable names (e.g. constants) may have `_` in their name\n- If you have to use a snake_case key in an object for some reasons, wrap it in\n quotation mark\n- This rule also applies to variables imported or exported via ES modules, but\n not to object properties of those variables\n\n### Invalid:\n\n```typescript\nlet first_name = \"Ichigo\";\nconst obj1 = { last_name: \"Hoshimiya\" };\nconst obj2 = { first_name };\nconst { last_name } = obj1;\n\nfunction do_something() {}\nfunction foo({ snake_case = \"default value\" }) {}\n\nclass snake_case_class {}\nclass Also_Not_Valid_Class {}\n\nimport { not_camelCased } from \"external-module.js\";\nexport * as not_camelCased from \"mod.ts\";\n\nenum snake_case_enum {\n snake_case_variant,\n}\n\ntype snake_case_type = { some_property: number };\n\ninterface snake_case_interface {\n some_property: number;\n}\n```\n\n### Valid:\n\n```typescript\nlet firstName = \"Ichigo\";\nconst FIRST_NAME = \"Ichigo\";\nconst __myPrivateVariable = \"Hoshimiya\";\nconst myPrivateVariable_ = \"Hoshimiya\";\nconst obj1 = { \"last_name\": \"Hoshimiya\" }; // if an object key is wrapped in quotation mark, then it's valid\nconst obj2 = { \"first_name\": first_name };\nconst { last_name: lastName } = obj;\n\nfunction doSomething() {} // function declarations must be camelCase but...\ndo_something(); // ...snake_case function calls are allowed\nfunction foo({ snake_case: camelCase = \"default value\" }) {}\n\nclass PascalCaseClass {}\n\nimport { not_camelCased as camelCased } from \"external-module.js\";\nexport * as camelCased from \"mod.ts\";\n\nenum PascalCaseEnum {\n PascalCaseVariant,\n}\n\ntype PascalCaseType = { someProperty: number };\n\ninterface PascalCaseInterface {\n someProperty: number;\n}\n```\n",
"docs": "Enforces the use of camelCase in variable names\n\nConsistency in a code base is key for readability and maintainability. This rule\nenforces variable declarations and object property names which you create to be\nin camelCase.\n\nOf note:\n\n- `_` is allowed at the start or end of a variable\n- All uppercase variable names (e.g. constants) may have `_` in their name\n- If you have to use a snake_case key in an object for some reasons, wrap it in\n quotation mark\n- This rule also applies to variables imported or exported via ES modules, but\n not to object properties of those variables\n\n### Invalid:\n\n```typescript\nlet first_name = \"Ichigo\";\nconst obj1 = { last_name: \"Hoshimiya\" };\nconst obj2 = { first_name };\n\nfunction do_something() {}\nfunction foo({ snake_case = \"default value\" }) {}\n\nclass snake_case_class {}\nclass Also_Not_Valid_Class {}\n\nexport * as not_camelCased from \"mod.ts\";\n\nenum snake_case_enum {\n snake_case_variant,\n}\n\ntype snake_case_type = { some_property: number };\n\ninterface snake_case_interface {\n some_property: number;\n}\n```\n\n### Valid:\n\n```typescript\nlet firstName = \"Ichigo\";\nconst FIRST_NAME = \"Ichigo\";\nconst __myPrivateVariable = \"Hoshimiya\";\nconst myPrivateVariable_ = \"Hoshimiya\";\nconst obj1 = { \"last_name\": \"Hoshimiya\" }; // if an object key is wrapped in quotation mark, then it's valid\nconst obj2 = { \"first_name\": first_name };\nconst { last_name } = obj1; // valid, because one has no control over the identifier\nconst { last_name: lastName } = obj;\n\nfunction doSomething() {} // function declarations must be camelCase but...\ndo_something(); // ...snake_case function calls are allowed\nfunction foo({ snake_case: camelCase = \"default value\" }) {}\n\nclass PascalCaseClass {}\n\nimport { not_camelCased } from \"external-module.js\"; // valid, because one has no control over the identifier\nimport { not_camelCased as camelCased } from \"external-module.js\";\nexport * as camelCased from \"mod.ts\";\n\nenum PascalCaseEnum {\n PascalCaseVariant,\n}\n\ntype PascalCaseType = { someProperty: number };\n\ninterface PascalCaseInterface {\n someProperty: number;\n}\n```\n",
"tags": []
},
{
Expand Down

0 comments on commit fd6d40b

Please sign in to comment.