Skip to content

Commit

Permalink
chore: refactor mime
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Dec 21, 2024
1 parent 6de5b73 commit 9c2ffa6
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/lint/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ import PrettierPluginSh from "prettier-plugin-sh";
import File from "#core/file";
import JSON5 from "#core/json5";
import Markdown from "#core/markdown";
import coreMime from "#core/mime";
import mime from "#core/mime";
import ansi from "#core/text/ansi";
import Table from "#core/text/table";
import * as utils from "#core/utils";
import uuid from "#core/uuid";

var terser, postcss, cssnano, htmlMinifier;

const mime = coreMime.clone();
const customMime = mime.clone();

mime.get( "application/json" ).extnames.add( [
customMime.get( "application/json" ).extnames.add( [

//
".gyp",
] );

mime.get( "application/x-sh" ).shebangs.add( [
customMime.get( "application/x-sh" ).shebangs.add( [

//
"#!/bin/sh",
Expand All @@ -35,13 +35,13 @@ mime.get( "application/x-sh" ).shebangs.add( [
"#!/usr/bin/env bash",
] );

mime.get( "application/node" ).shebangs.add( [
customMime.get( "application/node" ).shebangs.add( [

//
"#!/usr/bin/env node",
] );

mime.get( "application/x-sh" ).filenames.add( [
customMime.get( "application/x-sh" ).filenames.add( [

//
".gitignore",
Expand All @@ -50,14 +50,14 @@ mime.get( "application/x-sh" ).filenames.add( [
] );

// NOTE ".ts" conflicts with "video/mp2t"
mime.add( {
"type": "application/x-typescript",
customMime.add( {
"essence": "application/x-typescript",
"compressible": true,
"extnames": [ ".ts", ".tsx", ".mts", ".cts" ],
} );

mime.add( {
"type": "application/x-vue",
customMime.add( {
"essence": "application/x-vue",
"compressible": true,
"extnames": [ ".vue" ],
} );
Expand Down Expand Up @@ -309,10 +309,10 @@ export class LintFile {

// get by shebang
type ||= (
await mime.findByShebang( {
await customMime.findByShebang( {
"content": this.#data,
} )
)?.type;
)?.essence;

if ( type ) this.#type = TYPES[ type ];
}
Expand All @@ -321,7 +321,7 @@ export class LintFile {

// add default extension
if ( this.#type ) {
const extnames = mime.get( this.#type.type )?.extnames;
const extnames = customMime.get( this.#type.type )?.extnames;

if ( extnames?.default && !extnames.has( path.extname( this.path ) ) ) {
this.#fullPath += extnames.default;
Expand Down

0 comments on commit 9c2ffa6

Please sign in to comment.