Skip to content
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

no-atomics and no-shared-array-buffer not working #82

Open
GarfieldDeepClone opened this issue Sep 16, 2021 · 1 comment
Open

no-atomics and no-shared-array-buffer not working #82

GarfieldDeepClone opened this issue Sep 16, 2021 · 1 comment

Comments

@GarfieldDeepClone
Copy link

GarfieldDeepClone commented Sep 16, 2021

Hi :)

I've configured these 4 rules:
'es/no-atomics': 'error', 'es/no-shared-array-buffer': 'error', 'es/no-regexp-lookbehind-assertions': 'error', 'es/no-export-ns-from': 'error',

no-atomics and no-shared-array-buffer are not working.

This code snippet:
`const sab = new SharedArrayBuffer(1024);
const ta = new Uint8Array(sab);

	ta[0] = 5; // 5

	Atomics.add(ta, 0, 12); // 5
	// eslint-disable-next-line no-undef
	Atomics.load(ta, 0); // 17`

eslint (v7.32) doesn't prevent it from using. It says 'no-undef', and if adding this exception, everything is ok...

@ota-meshi
Copy link
Contributor

Hi @GarfieldDeepClone.

I think you need to use env or globals and configure them for global use.

https://eslint.org/docs/user-guide/configuring/language-options#specifying-environments
https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals

e.g.

{
    "env": {
        "es2021": true
    }
}
{
    "globals": {
        "SharedArrayBuffer": "readonly",
        "Atomics": "readonly"
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants