Refactor: Convert copy_files.cjs to ES module syntax
- Converted scripts/copy_files.cjs to use ES module syntax (renaming to copy_files.js). - This change aligns with the project's preference for ES modules over CommonJS for better modernity and future-proofing. - Updated eslint.config.js to remove the .cjs override. - Adjusted scripts/build_package.sh to call the new .js file.
This commit is contained in:
parent
3d74a7061e
commit
8b8fa6c1ae
|
@ -154,34 +154,6 @@ export default tseslint.config(
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Override for .cjs files to use CommonJS
|
|
||||||
{
|
|
||||||
files: ['**/*.cjs'],
|
|
||||||
languageOptions: {
|
|
||||||
sourceType: 'commonjs',
|
|
||||||
globals: {
|
|
||||||
...globals.node, // Add all Node.js globals
|
|
||||||
__dirname: 'readonly',
|
|
||||||
__filename: 'readonly',
|
|
||||||
exports: 'writable',
|
|
||||||
module: 'readonly',
|
|
||||||
require: 'readonly',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
// Disable rules that are not applicable to CommonJS
|
|
||||||
'@typescript-eslint/no-require-imports': 'off',
|
|
||||||
'no-restricted-syntax': [
|
|
||||||
'error',
|
|
||||||
// Keep other restricted syntaxes, but allow require for .cjs
|
|
||||||
{
|
|
||||||
selector: 'ThrowStatement > Literal:not([value=/^\\\\w+Error:/])',
|
|
||||||
message:
|
|
||||||
'Do not throw string literals or non-Error objects. Throw new Error("...") instead.',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// Prettier config must be last
|
// Prettier config must be last
|
||||||
prettierConfig,
|
prettierConfig,
|
||||||
// Custom eslint rules for this repo
|
// Custom eslint rules for this repo
|
||||||
|
|
|
@ -27,7 +27,7 @@ fi
|
||||||
tsc --build
|
tsc --build
|
||||||
|
|
||||||
# copy .{md,json} files
|
# copy .{md,json} files
|
||||||
node ../../scripts/copy_files.cjs
|
node ../../scripts/copy_files.js
|
||||||
|
|
||||||
# touch dist/.last_build
|
# touch dist/.last_build
|
||||||
touch dist/.last_build
|
touch dist/.last_build
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2025 Google LLC
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
// Copyright 2025 Google LLC
|
// Copyright 2025 Google LLC
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -13,8 +20,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
const fs = require('fs');
|
import fs from 'fs';
|
||||||
const path = require('path');
|
import path from 'path';
|
||||||
|
|
||||||
const sourceDir = path.join('src');
|
const sourceDir = path.join('src');
|
||||||
const targetDir = path.join('dist', 'src');
|
const targetDir = path.join('dist', 'src');
|
Loading…
Reference in New Issue