Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new plant module #2126

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/.vitepress/api-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const apiPages = [
{ text: 'Number', link: '/api/number.html' },
{ text: 'Person', link: '/api/person.html' },
{ text: 'Phone', link: '/api/phone.html' },
{ text: 'Plant', link: '/api/plant.html' },
{ text: 'Random', link: '/api/random.html' },
{ text: 'Science', link: '/api/science.html' },
{ text: 'String', link: '/api/string.html' },
Expand Down
1 change: 1 addition & 0 deletions scripts/generateLocales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const definitionsTypes: DefinitionType = {
music: 'MusicDefinition',
person: 'PersonDefinition',
phone_number: 'PhoneNumberDefinition',
plant: 'PlantDefinition',
science: 'ScienceDefinition',
system: 'SystemDefinition',
vehicle: 'VehicleDefinition',
Expand Down
2 changes: 2 additions & 0 deletions src/definitions/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { MetadataDefinition } from './metadata';
import type { MusicDefinition } from './music';
import type { PersonDefinition } from './person';
import type { PhoneNumberDefinition } from './phone_number';
import type { PlantDefinition } from './plant';
import type { ScienceDefinition } from './science';
import type { SystemDefinition } from './system';
import type { VehicleDefinition } from './vehicle';
Expand Down Expand Up @@ -46,6 +47,7 @@ export type LocaleDefinition = {
music?: MusicDefinition;
person?: PersonDefinition;
phone_number?: PhoneNumberDefinition;
plant?: PlantDefinition;
science?: ScienceDefinition;
system?: SystemDefinition;
vehicle?: VehicleDefinition;
Expand Down
1 change: 1 addition & 0 deletions src/definitions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type { MetadataDefinition } from './metadata';
export type { MusicDefinition } from './music';
export type { PersonDefinition, PersonTitleDefinition } from './person';
export type { PhoneNumberDefinition } from './phone_number';
export type { PlantDefinition } from './plant';
export type { ScienceDefinition } from './science';
export type { SystemDefinition, SystemMimeTypeEntryDefinition } from './system';
export type { VehicleDefinition } from './vehicle';
Expand Down
9 changes: 9 additions & 0 deletions src/definitions/plant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { LocaleEntry } from './definitions';

/**
* The possible definitions related to plants.
*/
export type PlantDefinition = LocaleEntry<{
tree: string[];
flower: string[];
}>;
2 changes: 2 additions & 0 deletions src/faker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { NumberModule } from './modules/number';
import type { PersonModule as NameModule } from './modules/person';
import { PersonModule } from './modules/person';
import { PhoneModule } from './modules/phone';
import { PlantModule } from './modules/plant';
import { RandomModule } from './modules/random';
import { ScienceModule } from './modules/science';
import { StringModule } from './modules/string';
Expand Down Expand Up @@ -144,6 +145,7 @@ export class Faker {
readonly person: PersonModule = new PersonModule(this);
readonly number: NumberModule = new NumberModule(this);
readonly phone: PhoneModule = new PhoneModule(this);
readonly plant: PlantModule = new PlantModule(this);
readonly science: ScienceModule = new ScienceModule(this);
readonly string: StringModule = new StringModule(this);
readonly system: SystemModule = new SystemModule(this);
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export type {
PhoneNumberDefinition,
/** @deprecated Use PhoneNumberDefinition instead */
PhoneNumberDefinition as PhoneNumberDefinitions,
PlantDefinition,
/** @deprecated Use AnimalDefinition instead */
PlantDefinition as PlantDefinitions,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant as this is a new definition that didnt exist before.

ScienceDefinition,
/** @deprecated Use ScienceDefinition instead */
ScienceDefinition as ScienceDefinitions,
Expand Down Expand Up @@ -121,6 +124,7 @@ export type {
SexType,
} from './modules/person';
export type { PhoneModule } from './modules/phone';
export type { PlantModule } from './modules/plant';
// eslint-disable-next-line deprecation/deprecation
export type { RandomModule } from './modules/random';
export type { ChemicalElement, ScienceModule, Unit } from './modules/science';
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import metadata from './metadata';
import music from './music';
import person from './person';
import phone_number from './phone_number';
import plant from './plant';
import science from './science';
import team from './team';
import vehicle from './vehicle';
Expand All @@ -45,6 +46,7 @@ const en: LocaleDefinition = {
music,
person,
phone_number,
plant,
science,
team,
vehicle,
Expand Down
103 changes: 103 additions & 0 deletions src/locales/en/plant/flower.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
export default [
'African Daisy',
'Agapanthus',
'Alstroemeria',
'Alyssum',
'Amaranthus',
'Amaryllis',
'Anemone',
'Angelonia',
'Anthurium',
'Aster',
'Astilbe',
'Baby’s Breath',
'Bachelor Button',
'Begonia',
'Bellflower',
'Bird of Paradise',
'Black-Eyed Susan',
'Bleeding Heart',
'Bougainvillea',
'Butterfly Bush',
'Caladium',
'Calendula',
'Calla Lily',
'Camellia',
'Canna',
'Carnation',
'Celosia',
'Chrysanthemum',
'Clematis',
'Columbine',
'Coneflower',
'Coreopsis',
'Cosmos',
'Crocus',
'Cyclamen',
'Daffodil',
'Dahlia',
'Daisy',
'Dianthus',
'Dusty Miller',
'Echinacea',
'Edelweiss',
'Eustoma',
'Freesia',
'Gardenia',
'Geranium',
'Gerbera Daisy',
'Gladiolus',
'Globe Amaranth',
'Hibiscus',
'Hosta',
'Hyacinth',
'Hydrangea',
'Iris',
'Jasmine',
'Kangaroo Paw',
'Lantana',
'Larkspur',
'Lavender',
'Liatris',
'Lilac',
'Lily',
'Lisianthus',
'Lobelia',
'Marigold',
'Morning Glory',
'Narcissus',
'Nasturtium',
'Nemesia',
'Nigella',
'Orchid',
'Pansy',
'Passion Flower',
'Peony',
'Petunia',
'Phlox',
'Pincushion Flower',
'Poppy',
'Primrose',
'Protea',
'Queen Anne’s Lace',
'Ranunculus',
'Rose',
'Salvia',
'Scabiosa',
'Snapdragon',
'Spider Flower',
'Star Jasmine',
'Statice',
'Stock',
'Sunflower',
'Sweet Pea',
'Tulip',
'Verbena',
'Veronica',
'Viola',
'Violet',
'Wax Flower',
'Wisteria',
'Yarrow',
'Zinnia',
];
14 changes: 14 additions & 0 deletions src/locales/en/plant/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { PlantDefinition } from '../../..';
import flower from './flower';
import tree from './tree';

const plant: PlantDefinition = {
flower,
tree,
};

export default plant;
161 changes: 161 additions & 0 deletions src/locales/en/plant/tree.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the trees, i think it would be better to keep the names to simpler, mostly one-word tree names. Then those could be used in other patterns like https://github.com/faker-js/faker/blob/next/src/locales/en/location/street_pattern.ts

For example "Pine Street" or "Ash Drive" is realistic, but "Lavender Twist Redbud Avenue" is not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should have a separate method/option for simple names?

Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
export default [
'Acacia',
'Alder',
'Almond',
'Amur Corktree',
'Apple',
'Arborvitae',
'Ash',
'Aspen',
'Australian Willow',
'Bald Cypress',
'Bamboo',
'Banyan',
'Basswood',
'Bay Laurel',
'Beech',
'Birch',
'Black Cherry',
'Black Locust',
'Black Oak',
'Black Walnut',
'Black Willow',
'Blue Spruce',
'Bottlebrush',
'Bradford Pear',
'Bristlecone Pine',
'Broadleaf Maple',
'Buckeye',
'Bur Oak',
'Butternut',
'California Buckeye',
'California Live Oak',
'California Redwood',
'California Sycamore',
'Catalpa',
'Cedar',
'Cherry',
'Chestnut',
'Chinese Elm',
'Chinkapin Oak',
'Cinnamon Tree',
'Colorado Blue Spruce',
'Common Hackberry',
'Common Lime',
'Copper Beech',
'Cork Oak',
'Cornelian Cherry',
'Cottonwood',
'Crab Apple',
'Crape Myrtle',
'Dawn Redwood',
'Deodar Cedar',
'Dogwood',
'Douglas Fir',
'Eastern Hemlock',
'Eastern Redbud',
'Eastern White Pine',
'English Oak',
'English Walnut',
'European Beech',
'European Hornbeam',
'European Larch',
'European Silver Fir',
'Fir',
'Flowering Dogwood',
'Flowering Plum',
'Forsythia',
'Gingko',
'Ginkgo Biloba',
'Golden Rain Tree',
'Grand Fir',
'Green Ash',
'Hawthorn',
'Hazelnut',
'Hickory',
'Holly',
'Honeylocust',
'Horse Chestnut',
'Japanese Cherry',
'Japanese Maple',
'Japanese Tree Lilac',
'Japanese Zelkova',
'Juniper',
'Katsura Tree',
'Kentucky Coffeetree',
'Larch',
'Lavender Twist Redbud',
'Lemon Tree',
'Leyland Cypress',
'Linden',
'Liquidambar',
'Locust',
'Longleaf Pine',
'Magnolia',
'Maidenhair Tree',
'Maple',
'Mimosa',
'Monterey Pine',
'Mountain Ash',
'Mulberry',
'Needle Fir',
'Norway Maple',
'Norway Spruce',
'Oak',
'Ohio Buckeye',
'Olive Tree',
'Paper Birch',
'Paperbark Maple',
'Pecan',
'Persian Ironwood',
'Persimmon',
'Pine',
'Pin Oak',
'Plane Tree',
'Plum',
'Ponderosa Pine',
'Poplar',
'Port Orford Cedar',
'Purple Leaf Plum',
'Quaking Aspen',
'Red Alder',
'Red Maple',
'Red Oak',
'Red Pine',
'Red Spruce',
'Redbud',
'River Birch',
'Sassafras',
'Saucer Magnolia',
'Scots Pine',
'Serviceberry',
'Shagbark Hickory',
'Shingle Oak',
'Silver Birch',
'Silver Maple',
'Smoke Tree',
'Sourwood',
'Southern Magnolia',
'Southern Red Oak',
'Spruce',
'Sugar Maple',
'Sweet Birch',
'Sweet Chestnut',
'Sweet Gum',
'Sycamore',
'Tamarack',
'Thornless Honeylocust',
'Tree Of Heaven',
'Tulip Tree',
'White Ash',
'White Fir',
'White Oak',
'White Pine',
'White Spruce',
'Willow',
'Witch Hazel',
'Yellow Birch',
'Yellowwood',
'Yew',
'Zelkova',
];
Loading