diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 00000000..442ae8f0 --- /dev/null +++ b/.eslintrc.cjs @@ -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'], + }, + ], +}; diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index b22edd03..00000000 --- a/.eslintrc.js +++ /dev/null @@ -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'], - }, - ], -}; diff --git a/javascript/just.config.cjs b/javascript/just.config.cjs index 096352ec..634fc523 100644 --- a/javascript/just.config.cjs +++ b/javascript/just.config.cjs @@ -39,7 +39,7 @@ function defineFlavor(flavor, env) { jestTask({ config: path.join(__dirname, 'jest.config.js'), nodeArgs: ['--experimental-vm-modules'], - env + env, }), ); task( @@ -52,14 +52,7 @@ defineFlavor('web'); task('build', series(emcmakeGenerateTask(), cmakeBuildTask())); -task( - 'test', - series( - emcmakeGenerateTask(), - 'cmake-build:web', - 'jest:web', - ), -); +task('test', series(emcmakeGenerateTask(), 'cmake-build:web', 'jest:web')); task( 'benchmark', @@ -90,11 +83,7 @@ task( ), ); -function recursiveReplace( - obj, - pattern, - replacement, -) { +function recursiveReplace(obj, pattern, replacement) { for (const [key, value] of Object.entries(obj)) { if (typeof value === 'string') { obj[key] = value.replace(pattern, replacement); @@ -133,13 +122,9 @@ function runBenchTask() { ]; logger.info(['node', ...args].join(' ')); - return spawn( - node, - args, - { - stdio: 'inherit', - }, - ); + return spawn(node, args, { + stdio: 'inherit', + }); }; }