Skip to content

Conversation

@jylep
Copy link
Contributor

@jylep jylep commented Sep 26, 2025

Adding missing top-level administrative equivalent of states for Norwegian locale (fylker)

  • Adds fallback to counties for states
  • Adds counties

https://en.wikipedia.org/wiki/Counties_of_Norway

@jylep jylep requested a review from a team as a code owner September 26, 2025 08:39
@netlify
Copy link

netlify bot commented Sep 26, 2025

Deploy Preview for fakerjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 64c6eb0
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/690b75e64bb6470008283cc7
😎 Deploy Preview https://deploy-preview-3617.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@xDivisionByZerox xDivisionByZerox added c: feature Request for new feature p: 1-normal Nothing urgent c: locale Permutes locale definitions m: location Something is referring to the location module labels Sep 26, 2025
@xDivisionByZerox xDivisionByZerox added this to the vAnytime milestone Sep 26, 2025
Copy link
Member

@xDivisionByZerox xDivisionByZerox left a comment

Choose a reason for hiding this comment

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

Thank you for your PR @jylep.

I see in the PR description that your intend was to add "top-level administrative" for Norway. I can see in the linked sources that this administrative level is called "county" in Norway. So I can see why you would put them into the "county.ts" file.

Please take a look at the descriptions of the county and state property in the location definition:

As you can see state represents the first-level administrative areas while county represents the second-level administrative areas. This has sadly been the case for quite some time due to the historic nature of the project heavily defaulting to the US state for structuring locale data sets.

After reading on the administrative divisions of Norway I would suggest putting the Norwegen "counties" (fylker) into Fakers "state" (first-level) property, while the Norwegen "municipalities" (kommune) would match Fakers "county" (second-level) property.

I can see that this might cause confusion due to the naming collision between Fakers naming definition and the real words application of these words. But, I'd say it is much better in the long run, to stay consistent and honor the specification of a fields when adding locale data to it. I can see the names of these entries change in the future to a more generic term, as we had this exact problem multiple times now.

Please tell me your opinion on the matter and thank you again for taking the initiative and time to making Faker better for anyone by providing these locale data.

@xDivisionByZerox xDivisionByZerox requested review from a team September 26, 2025 10:22
@matthewmayer
Copy link
Contributor

I tend to agree. For consistency let's put 1at level admin areas in state() and 2nd level in county() regardless of the official name.

@jylep
Copy link
Contributor Author

jylep commented Sep 27, 2025

Added kommuner (municipalities) as well for counties. 👍

matthewmayer
matthewmayer previously approved these changes Sep 27, 2025
@xDivisionByZerox
Copy link
Member

The test seem to be failing for multiple reasons:

  1. You locale data contain duplicate entries.
  2. You didn't update the snapshot tests.
  3. The formatter expects a different code styel.

To solve problem 1, it should be enough to regenerate the locales via the npm script generate:locales:

pnpm run generate:locales

# OR

npm run generate:locales

For the second problem you need to run the test with the -u flag. For this you can use the npm script test:update-snapshots:

pnpm run test:update-snapshots

# OR

npm run test:update-snapshots

The third problem can be solved by running the formatter locally:

pnpm run format

# OR

npm run format

@jylep Would you be so kind and run these scripts on your locale setup and commit the resulting changes afterwards? After that, the tests should be fixed.

matthewmayer
matthewmayer previously approved these changes Sep 28, 2025
ejcheng
ejcheng previously approved these changes Sep 29, 2025
@jylep jylep dismissed stale reviews from ejcheng and matthewmayer via 1a0a39c October 1, 2025 10:16
@jylep
Copy link
Contributor Author

jylep commented Oct 1, 2025

I tried to run tests locally to see what is causing the failing tests but I got way more errors that are likely unrelated (dynamic import errors)

The CI logs are not really giving me any info on what could be wrong. Just in case I ran the generate:locales, test:update-snapshot and format scripts without any resulting change.

@matthewmayer
Copy link
Contributor

Dynamic import errors suggest you may be using an old version of node.

Faker.js v10 requires a minimum of Node.js v20.19.0, v22.13.0, or v24.0.0.

@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.97%. Comparing base (6be2c20) to head (64c6eb0).
⚠️ Report is 2 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff            @@
##             next    #3617    +/-   ##
========================================
  Coverage   99.97%   99.97%            
========================================
  Files        2960     2961     +1     
  Lines      234711   235086   +375     
  Branches      932      930     -2     
========================================
+ Hits       234658   235033   +375     
  Misses         53       53            
Files with missing lines Coverage Δ
src/locales/nb_NO/location/county.ts 100.00% <100.00%> (ø)
src/locales/nb_NO/location/index.ts 100.00% <100.00%> (ø)
src/locales/nb_NO/location/state.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Shinigami92 Shinigami92 enabled auto-merge November 5, 2025 12:34
@Shinigami92 Shinigami92 added this pull request to the merge queue Nov 5, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 5, 2025
@matthewmayer matthewmayer added this pull request to the merge queue Nov 6, 2025
Merged via the queue into faker-js:next with commit 3dbcbe1 Nov 6, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: feature Request for new feature c: locale Permutes locale definitions m: location Something is referring to the location module p: 1-normal Nothing urgent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants