eslint-config-cobaltt7
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

eslint-config-cobaltt7

My ESLint style guide

Adding To A Project

  1. Note that this style guide only works for TypeScript projects, so ensure you have TypeScript installed and configured prior to setting up ESLint.

  2. Install the config by running:

    npm install eslint-config-cobaltt7 eslint --save-dev --save-exact
  3. Add the following to your package.json:

    "scripts": { "lint": "eslint" }
  4. Create an eslint.config.js file with the following content:

    import path from "node:path";
    import { fileURLToPath } from "node:url";
    
    import cobaltConfigs from "eslint-config-cobaltt7";
    import { defineConfig } from "eslint/config";
    
    export default defineConfig([
    	{ files: ["./**/*.ts"] },
    	...cobaltConfigs,
    	{
    		languageOptions: {
    			parserOptions: {
    				projectService: true,
    				tsconfigRootDir: path.dirname(fileURLToPath(import.meta.url)),
    			},
    		},
    	},
    ]);
  5. Add globalIgnores globs to omit certain files or folders from being linted, for example:

    @@ -1,10 +1,12 @@
     import path from "node:path";
     import { fileURLToPath } from "node:url";
    
     import cobaltConfigs, { declareConfig } from "eslint-config-cobaltt7";
    -import { defineConfig } from "eslint/config";
    +import { defineConfig, globalIgnores } from "eslint/configs";
    
     export default defineConfig([
     	{ files: ["./**/*.ts"] },
    +	globalIgnores(["./dist"]),
     	...cobaltConfigs,
     	{
     		languageOptions: {

    Make sure to put globalIgnores in the position indicated.

  6. Edit project-specific configuration, i.e. languageOptions, rules, and etcetera. Put all configuration in or after the last object containing languageOptions. The globals package is re-exported in eslint-config-cobaltt7, so it is unneccessary to reinstall it to modify global variables. Simply import it like so:

    import { globals } from "eslint-config-cobaltt7";
  7. To lint your code, simply run:

    node --run lint

Congrats! You've successfully integrated ESLint into your project with eslint-config-cobaltt7!

Importing specific configurations

The following configs are exported from this package independently:

import { configs } from "eslint-config-cobaltt7";

configs.global;
configs.configs;
configs.declarations;
configs.tests;

Please note that, with the exeption of global, all of these configs include files overrides that may need to be overridden for the config to behave as expected.

/eslint-config-cobaltt7/

    Package Sidebar

    Install

    npm i eslint-config-cobaltt7

    Weekly Downloads

    86

    Version

    1.2.0

    License

    MIT

    Unpacked Size

    22.3 kB

    Total Files

    11

    Last publish

    Collaborators

    • redguy12