Skip to content

Commit

Permalink
Merge branch 'main' into fix-exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscerie authored Mar 23, 2024
2 parents 837f3f9 + e73cccc commit f75516e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/Kampfkarren/selene/compare/0.26.1...HEAD)
### Added
- Added `CFrame.lookAlong` to the Roblox standard library

### Changed
- Updated the warning message for the `mixed_table` lint to include why mixed tables should be avoided

## [0.26.1](https://github.com/Kampfkarren/selene/releases/tag/0.26.1) - 2023-11-11
### Fixed
Expand Down
14 changes: 14 additions & 0 deletions docs/src/usage/std.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ Example:
type: any
```
#### "must_use"
This field is used for checking if the return value of a function is used.
- `false` - The default. The return value of this function does not need to be used.
- `true` - The return value of this function must be used.

Example:
```yml
tostring:
args:
- type: any
must_use: true
```

#### Argument types
- `"any"` - Allows any value.
- `"bool"`, `"function"`, `"nil"`, `"number"`, `"string"`, `"table"` - Expects a value of the respective type.
Expand Down
10 changes: 10 additions & 0 deletions selene-lib/default_std/roblox_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ globals:
must_use: true
CFrame.identity:
property: read-only
CFrame.lookAlong:
args:
- type:
display: Vector3
- type:
display: Vector3
- required: false
type:
display: Vector3
must_use: true
CFrame.lookAt:
args:
- type:
Expand Down
2 changes: 1 addition & 1 deletion selene-lib/src/lints/mixed_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Lint for MixedTableLint {
for mixed_table in visitor.mixed_tables {
diagnostics.push(Diagnostic::new_complete(
"mixed_table",
"mixed tables are not allowed".to_owned(),
"mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding".to_owned(),
Label::new(mixed_table.range),
vec!["help: change this table to either an array or dictionary".to_owned()],
Vec::new(),
Expand Down
2 changes: 1 addition & 1 deletion selene-lib/src/lints/roblox_incorrect_roact_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use if_chain::if_chain;
pub struct IncorrectRoactUsageLint;

// Assumes string includes quotes at start and end
fn is_lua_valid_table_key_identifier(string: &String) -> bool {
fn is_lua_valid_table_key_identifier(string: &str) -> bool {
// Valid identifier cannot start with numbers
let first_char = string.chars().nth(1).unwrap();
if !first_char.is_alphabetic() && first_char != '_' {
Expand Down
12 changes: 6 additions & 6 deletions selene-lib/tests/lints/mixed_table/mixed_table.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[mixed_table]: mixed tables are not allowed
error[mixed_table]: mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding
┌─ mixed_table.lua:2:5
2 │ ╭ "",
Expand All @@ -7,7 +7,7 @@ error[mixed_table]: mixed tables are not allowed
= help: change this table to either an array or dictionary

error[mixed_table]: mixed tables are not allowed
error[mixed_table]: mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding
┌─ mixed_table.lua:7:5
7 │ ╭ {},
Expand All @@ -16,7 +16,7 @@ error[mixed_table]: mixed tables are not allowed
= help: change this table to either an array or dictionary

error[mixed_table]: mixed tables are not allowed
error[mixed_table]: mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding
┌─ mixed_table.lua:12:5
12 │ ╭ a,
Expand All @@ -25,7 +25,7 @@ error[mixed_table]: mixed tables are not allowed
= help: change this table to either an array or dictionary

error[mixed_table]: mixed tables are not allowed
error[mixed_table]: mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding
┌─ mixed_table.lua:19:5
19 │ ╭ 1,
Expand All @@ -34,7 +34,7 @@ error[mixed_table]: mixed tables are not allowed
= help: change this table to either an array or dictionary

error[mixed_table]: mixed tables are not allowed
error[mixed_table]: mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding
┌─ mixed_table.lua:25:5
25 │ ╭ [c] = d,
Expand All @@ -43,7 +43,7 @@ error[mixed_table]: mixed tables are not allowed
= help: change this table to either an array or dictionary

error[mixed_table]: mixed tables are not allowed
error[mixed_table]: mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding
┌─ mixed_table.lua:30:5
30 │ ╭ a = b,
Expand Down

0 comments on commit f75516e

Please sign in to comment.