Skip to content

Commit

Permalink
Merge pull request #1062 from chromaui/cody/cap-2259-enable-unicornfi…
Browse files Browse the repository at this point in the history
…lename-case

Enable `unicorn/filename-case` ESLint rule
  • Loading branch information
codykaup authored Oct 1, 2024
2 parents c97b1b9 + e0cc85f commit 6fe6065
Show file tree
Hide file tree
Showing 37 changed files with 45 additions and 34 deletions.
2 changes: 1 addition & 1 deletion bin-src/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { config } from 'dotenv';
import { main as initMain } from './init';
import { main } from './main';
import { main as traceMain } from './trace';
import { main as trimMain } from './trim-stats-file';
import { main as trimMain } from './trimStatsFile';

config();

Expand Down
2 changes: 1 addition & 1 deletion bin-src/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import meow from 'meow';

import { getDependentStoryFiles } from '../node-src/lib/getDependentStoryFiles';
import { isPackageManifestFile } from '../node-src/lib/utils';
import { readStatsFile } from '../node-src/tasks/read-stats-file';
import { readStatsFile } from '../node-src/tasks/readStatsFile';
import { Context } from '../node-src/types';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mockfs from 'mock-fs';
import { afterEach, describe, expect, it } from 'vitest';

import { readStatsFile } from '../node-src/tasks/read-stats-file';
import { readStatsFile } from '../node-src/tasks/readStatsFile';
import * as trimmedFile from './__mocks__/previewStatsJson/preview-stats.trimmed.json';

mockfs({
Expand Down
2 changes: 1 addition & 1 deletion bin-src/trim-stats-file.ts → bin-src/trimStatsFile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { outputFile } from 'fs-extra';

import { readStatsFile } from '../node-src/tasks/read-stats-file';
import { readStatsFile } from '../node-src/tasks/readStatsFile';

const dedupe = <T>(array: T[]) => [...new Set(array)];
const isUserCode = ({ name, moduleName = name }: { name?: string; moduleName?: string }) =>
Expand Down
15 changes: 13 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,19 @@ export default [
unicorn.configs['flat/recommended'],
{
rules: {
// TODO: Switch this to 'error' when we are ready to enforce this rule
'unicorn/filename-case': ['off', { case: 'camelCase' }],
'unicorn/filename-case': [
'error',
{
case: 'camelCase',
ignore: [
// Allow capitalization in initialisms
String.raw`^.*DNS.*\.[jt]s$`,
String.raw`^.*CSF.*\.[jt]s$`,
String.raw`^.*TTY.*\.[jt]s$`,
String.raw`^.*CI.*\.[jt]s$`,
],
},
],
// Chromatic uses err as our catch convention.
// This is baked into pino transforms as well.
'unicorn/prevent-abbreviations': [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"lint:package": "sort-package-json",
"release": "node scripts/release.js",
"trace": "node -r esm bin-src/trace.js",
"trim-stats": "node -r esm bin-src/trim-stats-file.js",
"trim-stats": "node -r esm bin-src/trimStatsFile.js",
"storybook": "start-storybook -p 9009 -s static",
"test": "jest",
"prepare": "husky install && npm run build",
Expand Down
2 changes: 1 addition & 1 deletion node-src/__mocks__/dependencyChanges/berry-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"lint:package": "sort-package-json",
"release": "node scripts/release.js",
"trace": "node -r esm bin-src/trace.js",
"trim-stats": "node -r esm bin-src/trim-stats-file.js",
"trim-stats": "node -r esm bin-src/trimStatsFile.js",
"storybook": "start-storybook -p 9009 -s static",
"test": "jest",
"prepare": "husky install && npm run build",
Expand Down
14 changes: 7 additions & 7 deletions node-src/git/getParentCommits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { beforeAll, describe, expect, it, vi } from 'vitest';
import generateGitRepository from './generateGitRepository';
import { getParentCommits } from './getParentCommits';
import { getCommit } from './git';
import doubleLoopDescription from './mocks/double-loop';
import longLineDescription from './mocks/long-line';
import longLoopDescription from './mocks/long-loop';
import createMockIndex from './mocks/mock-index';
import simpleLoopDescription from './mocks/simple-loop';
import threeParentsDescription from './mocks/three-parents';
import twoRootsDescription from './mocks/two-roots';
import doubleLoopDescription from './mocks/doubleLoop';
import longLineDescription from './mocks/longLine';
import longLoopDescription from './mocks/longLoop';
import createMockIndex from './mocks/mockIndex';
import simpleLoopDescription from './mocks/simpleLoop';
import threeParentsDescription from './mocks/threeParents';
import twoRootsDescription from './mocks/twoRoots';

const descriptions = {
simpleLoop: simpleLoopDescription,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion node-src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ const mockStats = {
};
const mockStatsFile = Readable.from([JSON.stringify(mockStats)]);

vi.mock('./tasks/read-stats-file', () => ({
vi.mock('./tasks/readStatsFile', () => ({
readStatsFile: () => Promise.resolve(mockStats),
}));

Expand Down
8 changes: 4 additions & 4 deletions node-src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
getUncommittedHash,
getUserEmail,
} from './git/git';
import GraphQLClient from './io/GraphQLClient';
import HTTPClient from './io/HTTPClient';
import GraphQLClient from './io/graphqlClient';
import HTTPClient from './io/httpClient';
import checkForUpdates from './lib/checkForUpdates';
import checkPackageJson from './lib/checkPackageJson';
import { isE2EBuild } from './lib/e2e';
Expand All @@ -22,8 +22,8 @@ import { getConfiguration } from './lib/getConfiguration';
import getEnvironment from './lib/getEnvironment';
import getOptions from './lib/getOptions';
import { createLogger } from './lib/log';
import LoggingRenderer from './lib/LoggingRenderer';
import NonTTYRenderer from './lib/NonTTYRenderer';
import LoggingRenderer from './lib/loggingRenderer';
import NonTTYRenderer from './lib/nonTTYRenderer';
import parseArguments from './lib/parseArguments';
import { exitCodes, setExitCode } from './lib/setExitCode';
import { uploadMetadataFiles } from './lib/uploadMetadataFiles';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import retry from 'async-retry';

import { InitialContext } from '..';
import HTTPClient, { HTTPClientOptions } from './HTTPClient';
import HTTPClient, { HTTPClientOptions } from './httpClient';

const RETRYABLE_ERROR_CODE = 'RETRYABLE_ERROR_CODE';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion node-src/lib/uploadFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormData } from 'formdata-node';
import pLimit from 'p-limit';

import { Context, FileDesc, TargetInfo } from '../types';
import { FileReaderBlob } from './FileReaderBlob';
import { FileReaderBlob } from './fileReaderBlob';

/**
* Upload Storybook build files to Chromatic.
Expand Down
2 changes: 1 addition & 1 deletion node-src/lib/uploadMetadataFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { stat, writeFileSync } from 'fs';
import path from 'path';
import { withFile } from 'tmp-promise';

import { main as trimStatsFile } from '../../bin-src/trim-stats-file';
import { main as trimStatsFile } from '../../bin-src/trimStatsFile';
import { Context, FileDesc } from '../types';
import metadataHtml from '../ui/html/metadata.html';
import uploadingMetadata from '../ui/messages/info/uploadingMetadata';
Expand Down
2 changes: 1 addition & 1 deletion node-src/lib/uploadZip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { filesize } from 'filesize';
import { FormData } from 'formdata-node';

import { Context, TargetInfo } from '../types';
import { FileReaderBlob } from './FileReaderBlob';
import { FileReaderBlob } from './fileReaderBlob';

/**
* Upload a zip to Chromatic instead of individual files.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions node-src/tasks/upload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ vi.mock('../lib/compress');
vi.mock('../lib/getDependentStoryFiles');
vi.mock('../lib/findChangedDependencies');
vi.mock('../lib/findChangedPackageFiles');
vi.mock('./read-stats-file', () => ({
vi.mock('./readStatsFile', () => ({
readStatsFile: () =>
Promise.resolve({
modules: [
Expand All @@ -34,7 +34,7 @@ vi.mock('./read-stats-file', () => ({
}),
}));

vi.mock('../lib/FileReaderBlob', () => ({
vi.mock('../lib/fileReaderBlob', () => ({
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
FileReaderBlob: class {
constructor(_path: string, length: number, onProgress: (delta: number) => void) {
Expand Down
2 changes: 1 addition & 1 deletion node-src/tasks/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
uploading,
validating,
} from '../ui/tasks/upload';
import { readStatsFile } from './read-stats-file';
import { readStatsFile } from './readStatsFile';

interface PathSpec {
pathname: string;
Expand Down
4 changes: 2 additions & 2 deletions node-src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InitialContext } from '.';
import GraphQLClient from './io/GraphQLClient';
import HTTPClient from './io/HTTPClient';
import GraphQLClient from './io/graphqlClient';
import HTTPClient from './io/httpClient';
import type { Configuration } from './lib/getConfiguration';
import { Environment } from './lib/getEnvironment';
import { Logger } from './lib/log';
Expand Down
2 changes: 1 addition & 1 deletion node-src/ui/messages/errors/graphqlError.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GraphQLError } from '../../../io/GraphQLClient';
import { GraphQLError } from '../../../io/graphqlClient';
import graphqlError from './graphqlError';

export default {
Expand Down
2 changes: 1 addition & 1 deletion node-src/ui/messages/errors/graphqlError.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk';
import { dedent } from 'ts-dedent';

import { GraphQLError } from '../../../io/GraphQLClient';
import { GraphQLError } from '../../../io/graphqlClient';
import { error as icon } from '../../components/icons';
import link from '../../components/link';

Expand Down
2 changes: 1 addition & 1 deletion subdir/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"start": "start-storybook",
"build": "build-storybook --webpack-stats-json --output-dir ../subdir-static",
"postbuild": "node -r esm ../bin-src/trim-stats-file.js ../subdir-static/preview-stats.json"
"postbuild": "node -r esm ../bin-src/trimStatsFile.js ../subdir-static/preview-stats.json"
},
"dependencies": {
"@storybook/react": "^6.3.7",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import React from 'react';

import isChromatic from '..';
import AComponent from './A';
import isChromatic from '../isChromatic';
import AComponent from './a';

export default {
title: 'Tests',
Expand Down

0 comments on commit 6fe6065

Please sign in to comment.