Fix linting of CJS
This commit is contained in:
88
.eslintrc.cjs
Normal file
88
.eslintrc.cjs
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
root: true,
|
||||||
|
ignorePatterns: [
|
||||||
|
'/website',
|
||||||
|
'**/binaries/**',
|
||||||
|
'**/build/**',
|
||||||
|
'**/generated/**',
|
||||||
|
],
|
||||||
|
overrides: [
|
||||||
|
// Catch-all
|
||||||
|
{
|
||||||
|
files: ['**/*.?(m|c){j,t}s?(x)'],
|
||||||
|
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
|
||||||
|
plugins: ['prettier'],
|
||||||
|
rules: {
|
||||||
|
'no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
|
||||||
|
'no-var': 'error',
|
||||||
|
'prefer-arrow-callback': 'error',
|
||||||
|
'prefer-const': 'error',
|
||||||
|
'prefer-object-spread': 'error',
|
||||||
|
'prefer-spread': 'error',
|
||||||
|
'require-await': 'error',
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
es2020: true,
|
||||||
|
},
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 'latest',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// ES Modules
|
||||||
|
{
|
||||||
|
files: ['**/*.?(m){j,t}s?(x)'],
|
||||||
|
parserOptions: {
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// CommonJS Modules
|
||||||
|
{
|
||||||
|
files: ['**/*.c{j,t}s?(x)'],
|
||||||
|
env: {
|
||||||
|
commonjs: true,
|
||||||
|
},
|
||||||
|
parserOptions: {
|
||||||
|
sourceType: 'commonjs',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// TypeScript
|
||||||
|
{
|
||||||
|
files: ['**/*.?(m|c)ts?(x)'],
|
||||||
|
extends: ['plugin:@typescript-eslint/recommended'],
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
parserOptions: {
|
||||||
|
project: true,
|
||||||
|
},
|
||||||
|
plugins: ['@typescript-eslint'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/ban-ts-comment': 'off',
|
||||||
|
'@typescript-eslint/no-unused-vars': [
|
||||||
|
'error',
|
||||||
|
{argsIgnorePattern: '^_'},
|
||||||
|
],
|
||||||
|
'@typescript-eslint/no-var-requires': 'off',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Node
|
||||||
|
{
|
||||||
|
files: ['**/.*rc.(c){j,t}s', '**/*.config.?(c){j,t}s'],
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Jest
|
||||||
|
{
|
||||||
|
files: ['**/tests/**'],
|
||||||
|
extends: ['plugin:jest/recommended'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
65
.eslintrc.js
65
.eslintrc.js
@@ -1,65 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*
|
|
||||||
* @format
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
root: true,
|
|
||||||
ignorePatterns: [
|
|
||||||
'/website',
|
|
||||||
'**/binaries/**',
|
|
||||||
'**/build/**',
|
|
||||||
'**/generated/**',
|
|
||||||
],
|
|
||||||
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
|
|
||||||
plugins: ['prettier'],
|
|
||||||
rules: {
|
|
||||||
'no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
|
|
||||||
'no-var': 'error',
|
|
||||||
'prefer-arrow-callback': 'error',
|
|
||||||
'prefer-const': 'error',
|
|
||||||
'prefer-object-spread': 'error',
|
|
||||||
'prefer-spread': 'error',
|
|
||||||
'require-await': 'error',
|
|
||||||
},
|
|
||||||
env: {
|
|
||||||
es2020: true,
|
|
||||||
},
|
|
||||||
parserOptions: {
|
|
||||||
sourceType: 'module',
|
|
||||||
ecmaVersion: 'latest',
|
|
||||||
},
|
|
||||||
overrides: [
|
|
||||||
{
|
|
||||||
files: ['**/*.ts', '**/*.cts', '**/*.mts', '**/*.tsx'],
|
|
||||||
extends: ['plugin:@typescript-eslint/recommended'],
|
|
||||||
parser: '@typescript-eslint/parser',
|
|
||||||
parserOptions: {
|
|
||||||
project: true,
|
|
||||||
},
|
|
||||||
plugins: ['@typescript-eslint'],
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/ban-ts-comment': 'off',
|
|
||||||
'@typescript-eslint/no-unused-vars': [
|
|
||||||
'error',
|
|
||||||
{argsIgnorePattern: '^_'},
|
|
||||||
],
|
|
||||||
'@typescript-eslint/no-var-requires': 'off',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ['**/.eslintrc.js', '**/just.config.js'],
|
|
||||||
env: {
|
|
||||||
node: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ['**/tests/**'],
|
|
||||||
extends: ['plugin:jest/recommended'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
@@ -39,7 +39,7 @@ function defineFlavor(flavor, env) {
|
|||||||
jestTask({
|
jestTask({
|
||||||
config: path.join(__dirname, 'jest.config.js'),
|
config: path.join(__dirname, 'jest.config.js'),
|
||||||
nodeArgs: ['--experimental-vm-modules'],
|
nodeArgs: ['--experimental-vm-modules'],
|
||||||
env
|
env,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
task(
|
task(
|
||||||
@@ -52,14 +52,7 @@ defineFlavor('web');
|
|||||||
|
|
||||||
task('build', series(emcmakeGenerateTask(), cmakeBuildTask()));
|
task('build', series(emcmakeGenerateTask(), cmakeBuildTask()));
|
||||||
|
|
||||||
task(
|
task('test', series(emcmakeGenerateTask(), 'cmake-build:web', 'jest:web'));
|
||||||
'test',
|
|
||||||
series(
|
|
||||||
emcmakeGenerateTask(),
|
|
||||||
'cmake-build:web',
|
|
||||||
'jest:web',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
task(
|
task(
|
||||||
'benchmark',
|
'benchmark',
|
||||||
@@ -90,11 +83,7 @@ task(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
function recursiveReplace(
|
function recursiveReplace(obj, pattern, replacement) {
|
||||||
obj,
|
|
||||||
pattern,
|
|
||||||
replacement,
|
|
||||||
) {
|
|
||||||
for (const [key, value] of Object.entries(obj)) {
|
for (const [key, value] of Object.entries(obj)) {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
obj[key] = value.replace(pattern, replacement);
|
obj[key] = value.replace(pattern, replacement);
|
||||||
@@ -133,13 +122,9 @@ function runBenchTask() {
|
|||||||
];
|
];
|
||||||
logger.info(['node', ...args].join(' '));
|
logger.info(['node', ...args].join(' '));
|
||||||
|
|
||||||
return spawn(
|
return spawn(node, args, {
|
||||||
node,
|
stdio: 'inherit',
|
||||||
args,
|
});
|
||||||
{
|
|
||||||
stdio: 'inherit',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user