-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(rust_style): Rust-style naming convention rule #1323
base: main
Are you sure you want to change the base?
Conversation
); | ||
} | ||
_ => { | ||
self.check_pat(value, ctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?is ctx
valid everywhere, because it is passed to nested entities, see todo line 538?
("__fooBar_baz__", false), //not snake | ||
("__fooBarBaz__", false), //camel | ||
("Sha3_224", false), //not snake | ||
("SHA3_224", true), //screaming snake; todo: ?should this be true? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?according to camelcase.rs SHA3_224
is valid UpperCamelCase?
@@ -0,0 +1,1922 @@ | |||
// Copyright 2018-2024 the Deno authors + c-antin. All rights reserved. MIT license. | |||
// based on camelcase.rs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compare first commit with last commit for useful diff, because rust_style.rs
is based on camelcase.rs
docs/rules/rust_style.md
Outdated
const my_private_variable_ = "Hoshimiya"; | ||
const obj1 = { "lastName": "Hoshimiya" }; // if an object key is wrapped in quotation mark, then it's valid | ||
const obj2 = { "firstName": firstName }; | ||
const { lastName } = obj1; //valid, because one has no control over the identifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: #1187 changed this behavior, but camelcase.md did not get updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #1325
docs/rules/rust_style.md
Outdated
|
||
class PascalCaseClass {} | ||
|
||
import { camelCased } from "external-module.js"; //valid, because one has no control over the identifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: #1187 changed this behavior, but camelcase.md did not get updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #1325
for ident in idents { | ||
self.check_ident_snake_cased_or_screaming_snake_cased( | ||
&ident.range(), | ||
IdentToCheck::variable_or_constant(ident.to_id().0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?should global assign of camelCase variables be valid, because one has no control over the identifier?
if so, we should remove fn assign_expr
.
This rule is useful for deno projects that call rust functions via FFI. It attempts to unify naming conventions and enforces declarations and object property names which one creates to be
in UpperCamelCase/PascalCase for classes, types, interfaces,
in snake_case for functions, methods, variables
and in SCREAMING_SNAKE_CASE for static class properties and constants.
See #1322.