0.2.3 • Published 2 months ago

@born3am/eslint-config v0.2.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

eslint-config

ESlint "Flat" configuration for Born3am Projects

Pre-requisites

Check that @born3am/prettier package is properly installed and configured. Prettier is integrated with eslint and eslint will fail if it does not find the Prettier package and the prettier config file. Further details about Prettier can be found here(https://github.com/Born3am Projects/prettier-config).

Installation

1) Create an empty file .eslint.config.js in the root of your project.

2) Install the @born3am/eslint-config package as a dev dependency.

npm install --save-dev @born3am/eslint-config

The package @born3am/eslint-config includes the following dev-dependencies:

@eslint/eslintrc
eslint
eslint-config-prettier
eslint-plugin-deprecation
eslint-plugin-import
eslint-plugin-jsx-a11y
eslint-plugin-prettier
eslint-plugin-promise
eslint-plugin-react
eslint-plugin-simple-import-sort
eslint-plugin-typescript-sort-keys
eslint-plugin-jest
eslint-plugin-vitest
globals
typescript
typescript-eslint

... and the following peer-dependencies:

jest
prettier
typescript
vitest
vite-plugin-eslint

Usage

There are three primary preset configuration bundles, each tailored to a specific project type. Each configuration is an independent package module that can be imported and used separately in the .eslint.config.js file, as follows: 1) WebApps Projects Include eslint configs for React, Javascript and TypeScript files. The testing framework used in this context is Vitest.

  • Configs included (in this order):

    const eslintConfigWeb = [
      eslintConfigBase,
      eslintConfigImport,
      eslintConfigJs,
      eslintConfigTs,
      eslintConfigReact,
      eslintConfigVite,
      eslintConfigPrettier,
    ];
  • Usage in .eslint.config.js:

    // eslint.config.js
    import { eslintConfigWeb } from '@born3am/eslint-config'
    
    /** @type {import('eslint').Linter.FlatConfig[]} */
    export default eslintConfigWeb

2) NodeJS Projects Include eslint configs for Javascript and TypeScript files. The testing framework used in this context is Jest.

  • Configs included (in this order):

    const eslintConfigNode = [
      eslintConfigBase,
      eslintConfigImport,
      eslintConfigJs,
      eslintConfigTs,
      eslintConfigJest,
      eslintConfigPrettier,
    ];
  • Usage in .eslint.config.js:

    // eslint.config.js
    import { eslintConfigNode } from '@born3am/eslint-config'
    
    /** @type {import('eslint').Linter.FlatConfig[]} */
    export default eslintConfigNode

3) AppsScript Projects Include eslint configs for Javascript and Google Apps Script files. The testing framework used in this context is Jest.

  • Configs included (in this order):

      const eslintConfigAppsScript = [
        eslintConfigBase,
        eslintConfigJs,
        eslintConfigJest,
        eslintConfigPrettier,
      ];
  • Usage in .eslint.config.js:

    // eslint.config.js
    import { eslintConfigAppsScript } from '@born3am/eslint-config'
    
    /** @type {import('eslint').Linter.FlatConfig[]} */
    export default eslintConfigAppsScript

Scripts

Setup package.json Scripts:

{
 "scripts": {
    "lint": "eslint -c eslint.config.js --cache .",
    "lint:fix": "npm run lint -- --no-cache --fix",
    "prettier": "prettier --check --cache --no-error-on-unmatched-pattern '**/*.md' '**/*.yml' '**/*.json' '**/*.html' '**/*.css' '**/*.scss' '**/*.sass' '**/*.less'",
    "prettier:fix": "npm run prettier -- --no-cache --write",
    "fix": "npm run prettier:fix ; npm run lint:fix"
  }
}

prettier is integrated with eslint and rules from both are applied to all javascript/typescript files in one go, via the eslint script only.

Other files like .md, .yml, .json, .html, .css, .scss, .sass, .less are handled uniquely by prettier and linting rules cannot be applied to them inside eslint.config.js.

Regardless of the file type, the fix script should always handle all files.

Maintenance

To check for deprecated rules, resolve conflicts, update rules, or gain a better understanding of the rules, you can utilize the eslint-flat-config-viewer package.

Please note, this package isn't installed as a dependency and is solely used for rule viewing. As a standalone package, it can be executed without installation. To view the rules in a browser window, execute the following command in your terminal, making sure you're in the same directory as the .eslint.config.js file:

npx eslint-flat-config-viewer
acornacorn-jsxacorn-walkajvansi-escapesansi-regexansi-stylesanymatchargparsearia-queryarray-buffer-byte-lengtharray-includesarray-unionarray.prototype.filterarray.prototype.findlastarray.prototype.findlastindexarray.prototype.flatarray.prototype.flatmaparray.prototype.toreversedarray.prototype.tosortedarraybuffer.prototype.sliceassertion-errorast-types-flowasynciterator.prototypeavailable-typed-arraysaxe-coreaxobject-querybabel-jestbabel-plugin-istanbulbabel-plugin-jest-hoistbabel-preset-current-node-syntaxbabel-preset-jestbalanced-matchbrace-expansionbracesbrowserslistbserbuffer-fromcaccall-bindcallsitescamelcasecaniuse-litechaichalkchar-regexcheck-errorci-infocjs-module-lexercliuicocollect-v8-coveragecolor-convertcolor-nameconcat-mapconvert-source-mapcreate-jestcross-spawndamerau-levenshteindebugdedentdeep-eqldeep-isdeepmergedefine-data-propertydefine-propertiesdequaldetect-newlinediff-sequencesdir-globdoctrineelectron-to-chromiumemitteryemoji-regexerror-exes-abstractes-array-method-boxes-properlyes-define-propertyes-errorses-iterator-helperses-set-tostringtages-shim-unscopableses-to-primitiveesbuildescaladeescape-string-regexpeslint-import-resolver-nodeeslint-module-utilseslint-scopeeslint-visitor-keysespreeesprimaesqueryesrecurseestraverseestree-walkeresutilsexecaexitexpectfast-deep-equalfast-difffast-globfast-json-stable-stringifyfast-levenshteinfastqfb-watchmanfile-entry-cachefill-rangefind-upflat-cacheflattedfor-eachfs.realpathfseventsfunction-bindfunction.prototype.namefunctions-have-namesgensyncget-caller-fileget-func-nameget-intrinsicget-package-typeget-streamget-symbol-descriptionglobglob-parentglobalthisglobbygopdgraceful-fsgraphemerhas-bigintshas-flaghas-property-descriptorshas-protohas-symbolshas-tostringtaghasownhtml-escaperhuman-signalsignoreimport-freshimport-localimurmurhashinflightinheritsinternal-slotis-array-bufferis-arrayishis-async-functionis-bigintis-boolean-objectis-callableis-core-moduleis-date-objectis-extglobis-finalizationregistryis-fullwidth-code-pointis-generator-fnis-generator-functionis-globis-mapis-negative-zerois-numberis-number-objectis-path-insideis-regexis-setis-shared-array-bufferis-streamis-stringis-symbolis-typed-arrayis-weakmapis-weakrefis-weaksetisarrayisexeistanbul-lib-coverageistanbul-lib-instrumentistanbul-lib-reportistanbul-lib-source-mapsistanbul-reportsiterator.prototypejestjest-changed-filesjest-circusjest-clijest-configjest-diffjest-docblockjest-eachjest-environment-nodejest-get-typejest-haste-mapjest-leak-detectorjest-matcher-utilsjest-message-utiljest-mockjest-pnp-resolverjest-regex-utiljest-resolvejest-resolve-dependenciesjest-runnerjest-runtimejest-snapshotjest-utiljest-validatejest-watcherjest-workerjs-tokensjs-yamljsescjson-bufferjson-parse-even-better-errorsjson-schemajson-schema-traversejson-stable-stringify-without-jsonifyjson5jsonc-parserjsx-ast-utilskeyvkleurlanguage-subtag-registrylanguage-tagslevenlevnlines-and-columnslocal-pkglocate-pathlodash.mergeloose-envifyloupelru-cachemagic-stringmake-dirmakeerrormerge-streammerge2micromatchmimic-fnminimatchminimistmllymsnanoidnatural-comparenatural-compare-litenode-int64node-releasesnormalize-pathnpm-run-pathobject-assignobject-inspectobject-keysobject.assignobject.entriesobject.fromentriesobject.groupbyobject.hasownobject.valuesonceonetimeoptionatorp-limitp-locatep-tryparent-moduleparse-jsonpath-existspath-is-absolutepath-keypath-parsepath-typepathepathvalpicocolorspicomatchpiratespkg-dirpkg-typespossible-typed-array-namespostcssprelude-lsprettierprettier-linter-helperspretty-formatpromptsprop-typespunycodepure-randqueue-microtaskreact-isreflect.getprototypeofregenerator-runtimeregexp.prototype.flagsrequire-directoryresolveresolve-cwdresolve-fromresolve.exportsreusifyrimrafrolluprun-parallelsafe-array-concatsafe-regex-testsemverset-function-lengthset-function-nameshebang-commandshebang-regexside-channelsiginfosignal-exitsisteransislashsource-mapsource-map-jssource-map-supportsprintf-jsstack-utilsstackbackstd-envstring-lengthstring-widthstring.prototype.matchallstring.prototype.trimstring.prototype.trimendstring.prototype.trimstartstrip-ansistrip-bomstrip-final-newlinestrip-json-commentsstrip-literalsupports-colorsupports-preserve-symlinks-flagsynckittest-excludetext-tabletinybenchtinypooltinyspytmplto-fast-propertiesto-regex-rangets-api-utilstsconfig-pathstslibtsutilstype-checktype-detecttype-festtyped-array-buffertyped-array-byte-lengthtyped-array-byte-offsettyped-array-lengthtypescriptufounbox-primitiveundici-typesupdate-browserslist-dburi-jsv8-to-istanbulvitevite-nodevite-plugin-eslintvitestwalkerwhichwhich-boxed-primitivewhich-builtin-typewhich-collectionwhich-typed-arraywhy-is-node-runningwrap-ansiwrappywrite-file-atomicy18nyallistyargsyargs-parseryocto-queue
0.2.1

2 months ago

0.2.3

2 months ago

0.2.2

2 months ago

0.2.0

2 months ago

0.1.0

2 months ago