Common JavaScript File Extensions

1.0.4 · abandoned · verified Sun Apr 19

The `common-js-file-extensions` package provides two static arrays, `code` and `config`, listing various file extensions associated with JavaScript code and configuration files, respectively. It includes extensions for a wide range of JavaScript dialects and transpiled languages, such as standard `.js`, `.mjs`, `.cjs`, as well as older or less common ones like `.coffee`, `.ts`, `.iced`, `.es6`, `.jsx`, and `.json5`. Currently at version 1.0.4, the package appears to be stable but likely no longer actively maintained, given its last update years ago (copyright 2016). Its primary utility lies in offering a comprehensive, if somewhat dated, reference for tools needing to identify JavaScript-related files without needing to parse package manifests or project configurations for specific language tooling.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import the `code` and `config` arrays and iterate through the listed extensions. It also includes a basic example of checking a file's extension against these lists.

const { code, config } = require('common-js-file-extensions');

console.log('--- JavaScript Code File Extensions ---');
code.forEach(ext => console.log(`  .${ext}`));

console.log('\n--- JavaScript Config/Object File Extensions ---');
config.forEach(ext => console.log(`  .${ext}`));

// Example of checking a file extension
const fileName = 'my-component.tsx';
const fileExtension = fileName.split('.').pop();

if (fileExtension && code.includes(fileExtension)) {
  console.log(`\n'${fileName}' is a known JavaScript code file.`);
} else if (fileExtension && config.includes(fileExtension)) {
  console.log(`\n'${fileName}' is a known JavaScript config/object file.`);
} else {
  console.log(`\n'${fileName}' is not recognized as a common JS file type.`);
}

view raw JSON →