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

const phones ordered #2428

Closed
wants to merge 1 commit into from
Closed

const phones ordered #2428

wants to merge 1 commit into from

Conversation

alamparelli
Copy link

Ordered phones object in isMobilePhone.js to improve readability for future contributors

Good morning, I have ordered the key in the phones object to improve the readability for future contributions

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable) : N/A
  • Tests written (where applicable) : N/A
    • NPM test ran successfully
  • References provided in PR (where applicable) : N/A

Ordered to improve readability for future contributors
@WikiRik
Copy link
Member

WikiRik commented Jun 30, 2024

Thanks for this PR. Did you do this manually or with some kind of eslint rule (or something similar)? If there is an automatic way that we can check this, and other objects, that would be nice

@alamparelli
Copy link
Author

Thanks for this PR. Did you do this manually or with some kind of eslint rule (or something similar)? If there is an automatic way that we can check this, and other objects, that would be nice

Hello @WikiRik,
I did manually to not alter the way the code is builded.

May be some functions could be developed to sort automatically all the objects with a mechanism that could run prior to the npm test.

@alamparelli
Copy link
Author

@WikiRik,
I have searched yesterday and there is indeed an eslint plugin that could match the requirement but dependencies are not met in the project. I have not yet the experience to fix dependencies. I could have a look in a separate PR.

package.json

{
  "devDependencies": {
    "eslint": "^9.6.0",
    "eslint-plugin-perfectionist": "^2.11.0"
  }
}

eslint.config.mjs

import js from '@eslint/js';
import perfectionist from 'eslint-plugin-perfectionist'

export default [
	{
	  	plugins: {
		perfectionist,
	}, 
	rules: {
	'perfectionist/sort-objects': [
        'error',
        {
          'custom-groups': {
            id: 'id',
          },
          groups: ['id', 'unknown'],
          order: 'asc',
          'partition-by-comment': 'Part:**',
          type: 'natural',
        },
      ],		 
	},
	},
	js.configs.recommended,
	{
		rules: {
		},
	},
];
Screenshot 2024-07-02 at 07 15 31

@alamparelli alamparelli closed this by deleting the head repository Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants