Skip to content

croct-tech/coding-standard-js

Repository files navigation

Croct
JavaScript Coding Standard
A set of ESLint rules applied to all Croct JavaScript projects.

Version Build

📦 Releases · 🐞 Report Bug · ✨ Request Feature

Installation

The recommended way to install the package is via NPM. It pairs nicely with module bundlers such as Webpack or Browserify:

npm i -D @croct/eslint-plugin

This plugin uses ESLint's flat config format (ESLint v9+).

JavaScript

For JavaScript projects, create an eslint.config.mjs file:

import { defineConfig } from 'eslint/config';
import croct from '@croct/eslint-plugin';

export default defineConfig(
    croct.configs.javascript,
);

TypeScript

For TypeScript projects, create an eslint.config.mjs file:

import { defineConfig } from 'eslint/config';
import croct from '@croct/eslint-plugin';

export default defineConfig(
    croct.configs.typescript,
);

The TypeScript config includes the JavaScript preset, so there's no need to include both.

React

For React projects, create an eslint.config.mjs file:

import { defineConfig } from 'eslint/config';
import croct from '@croct/eslint-plugin';

export default defineConfig(
    croct.configs.react,
);

The React config includes the JavaScript preset, so there's no need to include both.

Cypress

For Cypress projects, create an eslint.config.mjs file:

import { defineConfig } from 'eslint/config';
import croct from '@croct/eslint-plugin';

export default defineConfig(
    croct.configs.cypress,
);

The Cypress config includes the JavaScript preset, so there's no need to include both.

Custom rules

You can add custom rules or override existing ones:

import { defineConfig } from 'eslint/config';
import croct from '@croct/eslint-plugin';

export default defineConfig(
    croct.configs.typescript,
    {
        files: ['src/**/*.ts'],
        rules: {
            '@typescript-eslint/explicit-function-return-type': 'off',
        },
    },
);

For the list of available presets and rules, see the reference documentation.

Basic usage

Run the following command to check if the project adheres to the coding standard:

eslint

Contributing

Contributions to the package are always welcome!

  • Report any bugs or issues on the issue tracker.
  • For major changes, please open an issue first to discuss what you would like to change.
  • Please make sure to update tests as appropriate.

Testing

Before running the test suites, the development dependencies must be installed:

npm i

Then, to run all tests:

npm run test

Copyright Notice

Copyright © 2015-2021 Croct Limited, All Rights Reserved.

All information contained herein is, and remains the property of Croct Limited. The intellectual, design and technical concepts contained herein are proprietary to Croct Limited s and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Croct Limited.

About

The coding-standard for JavaScript projects.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 6