Lua truthiness rule warns even for Boolean type

I haven't found much on truthiness in the help tab but I believe this should not be warning me considering columnIsFull is a boolean (it is happening everywhere else in my codebase).
No description
43 Replies
PepeElToro41
PepeElToro415mo ago
where did you get the bool?
Phantom
PhantomOP5mo ago
i defined it on the previous line
PepeElToro41
PepeElToro415mo ago
oh
Phantom
PhantomOP5mo ago
it is definitely 100% type boolean because it shows at the top
PepeElToro41
PepeElToro415mo ago
sometimes happens that if eslint cant detect some types and you get it from a type it will think is any
Phantom
PhantomOP5mo ago
should i try quickly adding a return type to the function and see if it fixes it
PepeElToro41
PepeElToro415mo ago
yeah maybe
Phantom
PhantomOP5mo ago
nope i will leave the return type there though because it helps with not making a silly mistake
Phantom
PhantomOP5mo ago
hmm would you like my .eslintrc isentinel may know something about this. idk i think he is like an eslint wizard or something
PepeElToro41
PepeElToro415mo ago
you could ask him, but I really have no idea why it would happen
Phantom
PhantomOP5mo ago
should i ping him? would he mind u think
iSentinel
iSentinel5mo ago
i just dont know if the original rile has some false positives
Phantom
PhantomOP5mo ago
sorry what exactly do you mean by this?
iSentinel
iSentinel5mo ago
rule* idk if the one in the plugin is broken
Phantom
PhantomOP5mo ago
well i mean if it were wouldnt everyone be experiencing this same issue? because so far it just seems like its me and pepe at one point i will just send the eslint rc because i dont really understand it at all
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"jsx": true,
"useJSXTextNode": true,
"ecmaVersion": 2018,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": [
"roblox-ts",
"@typescript-eslint",
"@typescript-eslint/eslint-plugin",
"prettier"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"plugin:roblox-ts/recommended"
],
"rules": {
"prettier/prettier": "warn",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-empty-function": "warn",
"prefer-const": [
"warn",
{
"destructuring": "all"
}
],
"no-undef-init": "error"
}
}
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"jsx": true,
"useJSXTextNode": true,
"ecmaVersion": 2018,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": [
"roblox-ts",
"@typescript-eslint",
"@typescript-eslint/eslint-plugin",
"prettier"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"plugin:roblox-ts/recommended"
],
"rules": {
"prettier/prettier": "warn",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-empty-function": "warn",
"prefer-const": [
"warn",
{
"destructuring": "all"
}
],
"no-undef-init": "error"
}
}
iSentinel
iSentinel5mo ago
what version of eslint do you have
Phantom
PhantomOP3mo ago
eslint@8.57.1 if you are asking about eslint-plugin-roblox-ts 0.0.36 that is the most recent version i think my eslint is quite outdated though it seems v9.28.0 is latest @iSentinel sorry for pinging you again a month later but have you found any potential causes?
iSentinel
iSentinel3mo ago
GitHub
GitHub - christopher-buss/eslint-plugin-roblox-ts-x: ESLint plugin ...
ESLint plugin for roblox-ts. Contribute to christopher-buss/eslint-plugin-roblox-ts-x development by creating an account on GitHub.
iSentinel
iSentinel3mo ago
it should support eslint 8 now @Phantom
Phantom
PhantomOP3mo ago
ah thanks! will give it a go in a sec
iSentinel
iSentinel3mo ago
only since last night tho i wrote some tests for it but i dont use eslint 8 myself so no promises
Phantom
PhantomOP3mo ago
this seems to have fixed it thank you very much!
Phantom
PhantomOP3mo ago
@iSentinel ah dang it nevermind
No description
Phantom
PhantomOP3mo ago
am i meant to remove all extensions except plugin:roblox-ts-x/recommended-legacy? i think i was, doing that only makes the error appear once
iSentinel
iSentinel3mo ago
@Phantom
Phantom
PhantomOP3mo ago
i dont believe i have @types in any of the 4 tsconfig.json files but i can send them here just in case i am doing something silly
{
"compilerOptions": {
// required
"allowSyntheticDefaultImports": true,
"downlevelIteration": true,
"jsx": "react",
"jsxFactory": "React.createElement",
"jsxFragmentFactory": "React.Fragment",
"module": "commonjs",
"moduleResolution": "Node",
"noLib": true,
"resolveJsonModule": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"moduleDetection": "force",
"strict": true,
"target": "ESNext",
"typeRoots": ["node_modules/@rbxts"],

// configurable
"baseUrl": ".",
"incremental": true,
"tsBuildInfoFile": "out/tsconfig.tsbuildinfo",
"noUncheckedIndexedAccess": true
}
}
{
"compilerOptions": {
// required
"allowSyntheticDefaultImports": true,
"downlevelIteration": true,
"jsx": "react",
"jsxFactory": "React.createElement",
"jsxFragmentFactory": "React.Fragment",
"module": "commonjs",
"moduleResolution": "Node",
"noLib": true,
"resolveJsonModule": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"moduleDetection": "force",
"strict": true,
"target": "ESNext",
"typeRoots": ["node_modules/@rbxts"],

// configurable
"baseUrl": ".",
"incremental": true,
"tsBuildInfoFile": "out/tsconfig.tsbuildinfo",
"noUncheckedIndexedAccess": true
}
}
// common place
{
"compilerOptions": {
"typeRoots": ["../../node_modules/@rbxts"],
"rootDir": "src",
"outDir": "out",
"baseUrl": "src",
"incremental": true,
"tsBuildInfoFile": "out/tsconfig.tsbuildinfo",
"paths": {
"common/*": ["../../common/src/*"],
"@common/*": ["../../common/src/*"]
}
},
"include": ["**/*", "../common/**/*"],
"extends": "../../tsconfig.json"
}
// common place
{
"compilerOptions": {
"typeRoots": ["../../node_modules/@rbxts"],
"rootDir": "src",
"outDir": "out",
"baseUrl": "src",
"incremental": true,
"tsBuildInfoFile": "out/tsconfig.tsbuildinfo",
"paths": {
"common/*": ["../../common/src/*"],
"@common/*": ["../../common/src/*"]
}
},
"include": ["**/*", "../common/**/*"],
"extends": "../../tsconfig.json"
}
// game place
{
"compilerOptions": {
"typeRoots": ["node_modules/@rbxts", "../../node_modules/@rbxts", "../common/src/*"],
"rootDirs": ["src", "../common/src"],
"outDir": "out",
"baseUrl": "src",
"paths": {
"common/*": ["./../../common/src/*"],
"types/*": ["./../src/types"]
}
},
"include": ["**/*", "../common/**/*"],
"extends": "../../tsconfig.json"
}
// game place
{
"compilerOptions": {
"typeRoots": ["node_modules/@rbxts", "../../node_modules/@rbxts", "../common/src/*"],
"rootDirs": ["src", "../common/src"],
"outDir": "out",
"baseUrl": "src",
"paths": {
"common/*": ["./../../common/src/*"],
"types/*": ["./../src/types"]
}
},
"include": ["**/*", "../common/**/*"],
"extends": "../../tsconfig.json"
}
// lobby place
{
"compilerOptions": {
"typeRoots": ["node_modules/@rbxts", "../../node_modules/@rbxts", "../common/src/*"],
"rootDirs": ["src", "../common/src"],
"outDir": "out",
"baseUrl": "src",
"paths": {
"common/*": ["./../../common/src/*"],
"types/*": ["./../src/types"]
}
},
"include": ["**/*", "../common/**/*"],
"extends": "../../tsconfig.json"
}
// lobby place
{
"compilerOptions": {
"typeRoots": ["node_modules/@rbxts", "../../node_modules/@rbxts", "../common/src/*"],
"rootDirs": ["src", "../common/src"],
"outDir": "out",
"baseUrl": "src",
"paths": {
"common/*": ["./../../common/src/*"],
"types/*": ["./../src/types"]
}
},
"include": ["**/*", "../common/**/*"],
"extends": "../../tsconfig.json"
}
i dont believe any of them have typeRoots of @types?
Phantom
PhantomOP3mo ago
sorry just to confirm copilot is partly wrong here right? because it shouldnt be erroring for variables which have their type resolving to boolean
No description
iSentinel
iSentinel3mo ago
boolean shouldn't need it no I'm not really sure, its been coming up for some people recently
Phantom
PhantomOP3mo ago
specifically lua truthiness? or just eslint acting strange
iSentinel
iSentinel3mo ago
yes specifically that rule
Phantom
PhantomOP3mo ago
is it a bad idea to turn it off until a fix is found
iSentinel
iSentinel3mo ago
i mean you dont need to have it on, its more of a guidance rule
Phantom
PhantomOP3mo ago
i know i like it lol
iSentinel
iSentinel3mo ago
if you know js truthiness and you're fine with it then its fine to turn off
Phantom
PhantomOP3mo ago
id prefer to have it on in case i accidentally look past an empty string or a number being falsy but i guess i dont really have a choice
iSentinel
iSentinel3mo ago
tbf i tend towards explicit anyway id probably do if gameDataMap !== undefined
Phantom
PhantomOP3mo ago
ah okay will do thanks again does this function exactly the same as how the eslint rule is supposed to function? because if it does cant the code be repurposed somehow i dont think there is a way to get around using the eslint plugin though if you want readable code that is
iSentinel
iSentinel3mo ago
It'd be nicer if the compiler had these methods exposed that it could hook into
Phantom
PhantomOP3mo ago
is the compiler written in typescript?
iSentinel
iSentinel3mo ago
For now
Phantom
PhantomOP3mo ago
alright im going to try disabling the rule and running the compiler with the --logTruthyChanges flag
iSentinel
iSentinel3mo ago
Yeah for these rules that are just meant to mimic the compiler it'd make sense

Did you find this page helpful?