Skip to content

Commit

Permalink
fix: ignore eslint in prompt message formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
niebag committed Apr 18, 2024
1 parent 96572cd commit 2b843ce
Show file tree
Hide file tree
Showing 7 changed files with 19,338 additions and 14,587 deletions.
21 changes: 6 additions & 15 deletions .plop-templates/component/index.tsx.hbs
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import * as React from 'react';

import { cn } from '~/lib/utils';

type Props = {
className?: string;
};

export function {{pascalCase name}}({ className, ...props }: Props) {
return (
<div data-testid='{{snakeCase name}}' className={cn('', className)}>
Hello, world!
</div>
);
}
import * as React from 'react'; import { cn } from '~/lib/utils'; type Props = { className?: string; }; export function
{{pascalCase name}}({ className, ...props }: Props) { return (
<div data-testid='{{snakeCase name}}' className="{cn(''," className)}>
Hello, world!
</div>
); }
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# handlebars
*.hbs
10 changes: 5 additions & 5 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ await import('./src/env.js');

/** @type {import('next').NextConfig} */
const config = {
logging: {
fetches: {
fullUrl: true
}
}
logging: {
fetches: {
fullUrl: true
}
}
};

export default config;
4 changes: 2 additions & 2 deletions next.constants.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

import { env } from "~/env";
import { env } from '~/env';

/**
* This is used to verify if the current site is running on a development environment.
*/
export const IS_DEVELOPMENT = env.NODE_ENV === 'development';
export const IS_DEVELOPMENT = env.NODE_ENV === 'development';
92 changes: 47 additions & 45 deletions plopfile.mjs
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
/**
* @param {import('plop').NodePlopAPI} plop - Plop provides the API methods for plop actions
*/
export default function (
plop
) {
plop.setGenerator('component', {
description: 'Create a new component according to the Atomic Design methodology',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your component name?'
},
{
type: 'list',
name: 'type',
message: 'What is your component type? ',
choices: ['atoms', 'molecules', 'organisms']
},
{
type: 'input',
name: 'subType',
message: `What is your component sub-type? (e.g. 'typography' for atoms, 'cards' for molecules or 'sections' for organisms)`,
},
{
type: 'confirm',
name: 'confirmation',
message: (answers) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
const pascalCaseName = answers.name.replace(/(^\w|-\w|\s\w|_\w)/g, (/** @type {string} */ s) => s.toUpperCase()).replace(/[-_\s]+/g, '');
export default function (plop) {
plop.setGenerator('component', {
description: 'Create a new component according to the Atomic Design methodology',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your component name?'
},
{
type: 'list',
name: 'type',
message: 'What is your component type? ',
choices: ['atoms', 'molecules', 'organisms']
},
{
type: 'input',
name: 'subType',
message: `What is your component sub-type? (e.g. 'typography' for atoms, 'cards' for molecules or 'sections' for organisms)`
},
{
type: 'confirm',
name: 'confirmation',
message: (answers) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
const pascalCaseName = answers.name
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
.replace(/(^\w|-\w|\s\w|_\w)/g, (/** @type {string} */ s) => s.toUpperCase())
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
.replace(/[-_\s]+/g, '');

return `Are you sure you want to create '~/components/${answers.type}/${answers.subType}/${pascalCaseName}'?`;
},
}
],
actions: [
{
type: 'add',
path: 'src/components/{{type}}/{{subType}}/{{pascalCase name}}/index.stories.tsx',
templateFile: '.plop-templates/component/index.stories.tsx.hbs'
},
{
type: 'add',
path: 'src/components/{{type}}/{{subType}}/{{pascalCase name}}/index.tsx',
templateFile: '.plop-templates/component/index.tsx.hbs'
},
]
});
return `Are you sure you want to create '~/components/${answers.type}/${answers.subType}/${pascalCaseName}'?`;
}
}
],
actions: [
{
type: 'add',
path: 'src/components/{{type}}/{{subType}}/{{pascalCase name}}/index.stories.tsx',
templateFile: '.plop-templates/component/index.stories.tsx.hbs'
},
{
type: 'add',
path: 'src/components/{{type}}/{{subType}}/{{pascalCase name}}/index.tsx',
templateFile: '.plop-templates/component/index.tsx.hbs'
}
]
});
}
Loading

0 comments on commit 2b843ce

Please sign in to comment.