Coder Social home page Coder Social logo

eslint-config-wesbos's Introduction

No-Sweat™ Eslint and Prettier Setup

These are my settings for ESLint and Prettier

You might like them - or you might not. Don't worry you can always change them.

What it does

  • Lints JavaScript and TypeScript based on the latest standards
  • Fixes issues and formatting errors with Prettier
  • Lints + Fixes inside of html script tags
  • Lints + Fixes React via eslint-config-airbnb
  • You can see all the rules here - these generally abide by the code written in my courses. You are very welcome to overwrite any of these settings, or just fork the entire thing to create your own.

Project Install

It's recommended you install this once per every project. ESLint used to have global configs, but no longer.

  1. If you don't already have a package.json file, create one with npm init -y.

  2. Then we need to install this config

npm install eslint-config-wesbos
  1. We need to put our eslint settings in a file in the root of your project. I prefer to use our existing package.json, and add an eslintConfig property. You can also create a new .eslintrc or .eslintrc.js file that lives where package.json does:

in package.json, add this anywhere top level. Like right under your "scripts" object.

"eslintConfig": {
  "extends": ["wesbos"]
}

Or put this in a .eslintrc file

{
  "extends": ["wesbos"]
}

For TypeScript projects, use wesbos/typescript.

{
  "extends": ["wesbos/typescript"]
}

TypeScript users will also need a tsconfig.json file in their project. An empty object ({}) or my base will do!

  1. You can add two scripts to your package.json to lint and/or fix:
"scripts": {
  "lint": "eslint .",
  "lint:fix": "eslint . --fix"
},
  1. Now you can manually lint your code by running npm run lint and fix all fixable issues with npm run lint:fix. You probably want your editor to do this though.

Settings

If you'd like to overwrite eslint or prettier settings, you can add the rules in your .eslintrc file. The ESLint rules go directly under "rules".

{
  "extends": [
    "wesbos"
  ],
  "rules": {
    "no-console": 2,
  }
}

Prettier Rules

There are only 2 prettier rules included in my config - singleQuote: true and endOfLine: 'auto'.

If you want custom prettier options, it's recommended to create a .prettierrc file in your root directory like so:

{
  "singleQuote": true,
  "endOfLine": "auto",
  "tabWidth": 4
}

You can also put this in your EsLint config as a rule like so:

{
  "extends": ["wesbos"],
  "rules": {
    ... any eslint rules here
    "prettier/prettier": [
      "error",
      {
        "singleQuote": true,
        "endOfLine": "auto",
        "tabWidth": 4
      },
    ],
  }
}

Note if you are switching to double quotes, you'll also need to add this eslint rule, or they will fight to the death!

quotes: ["error", "double"];

With VS Code

You should read this entire thing. Serious!

Once you have done one, or both, of the above installs. You probably want your editor to lint and fix for you. Here are the instructions for VS Code:

  1. Install the ESLint package
  2. Now we need to setup some VS Code settings via Code/FilePreferencesSettings. It's easier to enter these settings while editing the settings.json file, so click the Open (Open Settings) icon in the top right corner:
// These are all my auto-save configs
"editor.formatOnSave": true,
// turn it off for JS and JSX, we will do this via eslint
"[javascript][javascriptreact][typescript][typescriptreact]": {
  "editor.formatOnSave": false
},
// tell the ESLint plugin to run on save
"editor.codeActionsOnSave": {
  "source.fixAll.eslint": true
},

After attempting to lint your file for the first time, you may need to click on 'ESLint' in the bottom right and select 'Allow Everywhere' in the alert window.

Finally you'll usually need to restart VS code. They say you don't need to, but it's never worked for me until I restart.

With Create React App

  1. Run npx install-peerdeps --dev eslint-config-wesbos
  2. Crack open your package.json and replace "extends": "react-app" with "extends": "wesbos"

With Gatsby

  1. Run npx install-peerdeps --dev eslint-config-wesbos
  2. follow the Local / Per Project Install steps above

With WSL

It should work as above.

With JetBrains Products (IntelliJ IDEA, WebStorm, RubyMine, PyCharm, PhpStorm, etc)

If you have previously configured ESLint to run via a File Watcher, turn that off.

If you choose Local / Per Project Install Above

  1. Open ESLint configuration by going to File > Settings (Edit > Preferences on Mac) > Languages & Frameworks > Code Quality Tools > ESLint (optionally just search settings for "eslint")
  2. Select Automatic ESLint Configuration
  3. Check Run eslint --fix on save

If you choose Global Install

The following steps are for a typical Node / ESLint global installtion. If you have a customized setup, refer to JetBrains docs for more ESLint Configuration Options.

  1. Open ESLint configuration by going to File > Settings (Edit > Preferences on Mac) > Languages & Frameworks > Code Quality Tools > ESLint (optionally just search settings for "eslint")
  2. Select Manual ESLint configuration
  3. Choose your Node interpreter from the detected installations
  4. Select the global ESLint package from the dropdown
  5. Leave Configuration File as Automatic Search
  6. Check Run eslint --fix on save

Ensure the Prettier plugin is disabled if installed.

  1. Open Prettier configuration by going to File > Settings (Edit > Preferences on Mac) > Languages & Frameworks > Code Quality Tools > Prettier (optionally just search settings for "prettier")
  2. Uncheck both On code reformat and On save
  3. Optional BUT IMPORTANT: If you have the Prettier extension enabled for other languages like CSS and HTML, turn it off for JS since we are doing it through Eslint already.
    1. Make sure the Run for files glob does not include js,ts,jsx,tsx.
    2. An example glob for styles, config, and markdown. {**/*,*}.{yml,css,sass,md}

With Typescript

Same instructions as above, just make sure you extend wesbos/typescript instead of just wesbos.

With Yarn

It should just work! Open an issue if not.

With pnpm

It should just work! Open an issue if not.

Issues with ESLint not formatting code

If you experience issues with ESLint not formatting the code or you receive a Parsing error: Cannot find module '@babel/preset-react error message then you need to check that you opened the folder where you installed and configured ESLint directly in VS Code. The correct folder to open will be the one where you installed the eslint-config-wesbos npm package and where you created the .eslintrc file.

Opening a parent folder or child folder in your code editor will cause ESLint to fail in finding the ESLint npm packages and the formatting won't work.

your-username
  |
  projects
    |
    beginner-javascript # <- Open this folder directly in your code editor
      .eslintrc
      package.json
      node_modules/
      exercises/
      playground/

eslint-config-wesbos's People

Contributors

0xflotus avatar adebiyial avatar andymantell avatar arapl3y avatar asjas avatar dependabot[bot] avatar endormi avatar gillkyle avatar jimueller avatar johanquiroga avatar mhesham32 avatar nickymeuleman avatar rdhar avatar robertotcestari avatar smakosh avatar svikas641 avatar thebrandonallen avatar vpicone avatar wesbos avatar zaklaughton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eslint-config-wesbos's Issues

Love your config but have a quick question

Love your config! But if I don't want to run your config every single time and then copy paste in my modifications to the eslintrc.

How would you recommend I go about making my own config? My theory:
Approach 1: I fork yours and then add my edits to the .eslint.js file
BUT
How is the eslint.js file different from an eslintrc file? They clearly have different structures to their format.
Approach 2: create my own config and pull in your project as a dep in the same way that you pull in airbnbs. But when I tried estlint --inti I didn't really see how I was supposed to include yours as a dep in the way that you included airbnbs. Any suggestions?

Also I like your handy npx install script but not clear how I would modify that part either. I see that install-peer-deps is an npm repo for installing peer deps. That seems self explanatory but how is running that repo to install peer deps different than if I just ran "npm install eslint-config-wesbos"? Why is the "install-peerdeps" thing necessary?

create-react-app does NOT need ejecting

You can use eslint with CRA without ejecting!

I've updated my fork's installation steps for CRA - you can take them & update yours too.

TL;DR:

  1. Run npx install-peerdeps eslint-config-sarpik --dev --yarn
  2. Crack open your package.json and
    1. replace "extends": "react-app" with "extends": "sarpik"
    2. replace "eslint": "5.x" with "eslint": "6.x" like so: yarn add [email protected], or replace yourself & run yarn install
      1. verify that eslint's version is 6.x.y: run node node_modules/.bin/eslint --version
    3. append --ext js,jsx,ts,tsx to eslint every time you call it (required for eslint 6.x, see kiprasmel#4)

Your package.json should have this:

{
	"scripts": {
		"lint": "    eslint . --ext js,jsx,ts,tsx",
		"lint:fix": "eslint . --ext js,jsx,ts,tsx --fix"
	},
	"eslintConfig": {
		"extends": "sarpik"
	},
	"devDependencies": {
		"<other-dev-dependency>": "<version>",
		"eslint": "6.x"
	}
}

Try it out:

npx create-react-app cra-eslint-ts --template typescript # typescript is optional
cd cra-eslint-ts

and then follow the steps above.

Finally, run yarn lint and yarn lint:fix & verify that yarn start still works 🚀

Outcome: https://github.com/sarpik/cra-eslint-ts

ERR undefined

install-peerdeps v3.0.3
Installing peerdeps for eslint-config-wesbos@latest.
npm install [email protected] babel-eslint@^10.1.0 eslint@^7.8.1 eslint-config-airbnb@^18.2.0 eslint-config-prettier@^6.11.0 
eslint-plugin-html@^6.1.0 eslint-plugin-import@^2.22.0 eslint-plugin-jsx-a11y@^6.3.1 eslint-plugin-prettier@^3.1.4 eslint-plugin-react@^7.20.6 eslint-plugin-react-hooks@^4.1.2 prettier@^2.1.1 --save-dev

ERR undefined

Not sure whats happening here. See below for my node and npm versions:

C:\Users\ranli\Desktop\Git local\JS_vanilla>node -v
v16.2.0

C:\Users\ranli\Desktop\Git local\JS_vanilla>npm -v
7.13.0

Question: Using with Intellij products

I'm using VSCode, but several of my teammates use Rubymine and they're having some issues with fixing everything via ESlint.
Basically, they use a File Watcher to run Eslint, but apparently it's pretty slow there. I'm wondering if anyone here works with this setup but with Intellij.

Intellij has good prettier support, so we were thinking of leaving prettier as the sole formatter, and then eslint autofix only on a precommit hook. But... my problem is that I must have the react-hooks/exhaustive-deps eslint rule running with autofix, or else people might have bugs that they won't know about...

Anyone using Intellij have a good workflow going on here?
Thanks!!

Configuration for rule "no-unused-vars" is invalid

I've been using this config for a while and a couple of weeks ago the eslint stopped working and kinda the intellisense paths on import, so I thought it was an issue from vs code but when I try to run the eslint command I'm having this issue.

Error: .eslintrc » eslint-config-wesbos:
        Configuration for rule "no-unused-vars" is invalid:
        Value {"ignoreSiblings":true,"argsIgnorePattern":"res|next|^err"} should be equal to one of the allowed values.
        Value {"ignoreSiblings":true,"argsIgnorePattern":"res|next|^err"} should NOT have additional properties.
        Value {"ignoreSiblings":true,"argsIgnorePattern":"res|next|^err"} should match exactly one schema in oneOf.

Supposedly at the next files from node-modules/eslint/*:

config-validator.js:132:19
config-validator.js:187:9
config-validator.js:184:30
config-validator.js:312:9
cascading-config-array-factory.js:464:13
cascading-config-array-factory.js:275:21
file-enumerator.js:431:49
file-enumerator.js:287:49

npx install-peerdeps hangs

When I run the command npx install-peerdeps --global eslint-config-wesbox
I first get an error that the "path" argument must be of type string
then it says it installed npx
then it launches cli.js and then hangs.

I've let it wait for 20+ min. Nothing.
I ran the uninstall command both globally and local, deleted the node_modules directory and tried to re-run the npx command. same problem.

VS Code - Windows - cannot find module eslint-config-wesbos

Getting this error:

[Info - 4:27:39 PM] ESLint server stopped.
[Info - 4:27:40 PM] ESLint server running in node v10.2.0
[Info - 4:27:40 PM] ESLint server is running.
[Info - 4:27:43 PM] ESLint library loaded from: c:\dev\projectname\node_modules\eslint\lib\api.js
[Error - 4:27:43 PM] Cannot find module 'eslint-config-wesbos' Referenced from: C:\Users\username\.eslintrc

Does it have something to do with ESLint attempting to reference my project's local node_modules even though I installed this globally? I have no dev dependencies in this particular package.json.

TabWidth

I'm using your config but just a question, why do you use 8 in the tab width? 😃

WSL

Anyone got this working on WSL. can't for the life of me get it working. Followed Wes's steps but not for windows as I want it working within Linux

[Info - 16:00:26] ESLint server stopped.
[Info - 16:00:27] ESLint server running in node v10.2.0
[Info - 16:00:27] ESLint server is running.
[Info - 16:00:28]

Not sure why it says node version 10 when I have 12 installed

Any help would be great

create react app issue

Install could be streamlined a bit as if you install it in create react app projects, you run into this issue (create react app uses "babel-eslint": "9.0.0" and this installs version 10.0.1 )
eslint/eslint#11229

Using together with typescript?

Hello,

I'm using typescript quite often & would love to use this same config for typescript projects aswell.

I thought maybe someone has already encountered & solved this use case & could share the solution - thanks!

After installing per instructions, the linter functionality works but not the Prettier functionality (in VS Code)

I installed as per instructions on Xubuntu. I did the global install the first time, but I learned that yes it is deprecated so I followed the instructions on the bottom of the screen to uninstall all of that, and then I did a local install. After leaving the .eslintrc file as
{
"extends": {
"wesbos"
]
}
the ESLinter linter functionality seems to work, but I cannot see any Prettier functionality.

ERR spawn npm ENOENT on Windows 10.

Just started getting the following error when attempting a local install:

install-peerdeps v3.0.0
ERR spawn npm ENOENT

It's been working for ages just fine. Any ideas what this could be?

Ta

eslint conflict when implementing this in create react app

react scripts uses [email protected] but we are using eslint7 something, so react script preventing us to do that it also showing this
Manually installing incompatible versions is known to cause hard-to-debug issues. If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That will permanently disable this message but you might encounter other issues.
the way i got rid from this is by installing the [email protected] . Should we mention this in installation guide ?

Running eslint gives error "Error: Cannot find module 'eslint-config-wesbos'"

I am using this on a Gatsby site so followed the instructions for a project-based install. I ran npx [email protected] --dev eslint-config-wesbos due to some dependency issues and everything installed successfully.

I then added the lint and lint:fix scripts to my package.json but running either script causes the Terminal to hang. So I ran eslint . and got the error "Error: Cannot find module 'eslint-config-wesbos" which might explain why the scripts weren't running.

I have checked my node_modules and eslint-config-wesbos directory and files are all there. Any ideas?

npm warn eslint-plugin-import

I am trying to run the global install but I keep getting this warning

npm WARN [email protected] requires a peer of eslint-plugin-import@^2.17.2 but none is installed. You must install peer dependencies yourself.

I have tried installing it but I keep getting more error to follow. Is this something I need to be worried about or is it fine to ignore? I also can't seem to get my inline javascript to fix itself in html files. I'm not sure if this is related. Is there any way for this to work or am I misunderstanding what this does?

ESlint failing to start due to React dependency?

I've done the walk-thru multiple times (including the part where I have to uninstall everything and start over again.

ESlint isn't doing anything to re-format malformed lines as shown in the video. When I click on the 'ESlint' icon in the toolbar (which has to be enabled separately now, apparently) I get the lines shown below:

[Info  - 12:14:59 AM] ESLint server running in node v12.8.1
[Info  - 12:14:59 AM] ESLint server is running.
[Info  - 12:17:16 AM] ESLint library loaded from: C:\Users\memil\Downloads\Beginner Javascript\course files\node_modules\eslint\lib\api.js
Warning: React version was set to "detect" in eslint-plugin-react settings, but the "react" package is not installed. Assuming latest React version for linting.
[Info  - 12:17:18 AM] Error while loading rule 'react/jsx-no-bind': Cannot find module 'react' from 'C:\Users\memil\Downloads\Beginner Javascript\course files' Occurred while linting C:\Users\memil\Downloads\Beginner Javascript\course files\playground\some-FINISHED.js
[Info  - 12:21:19 AM] Error while loading rule 'react/display-name': Cannot find module 'react' from 'C:\Users\memil\Downloads\Beginner Javascript\course files' Occurred while linting C:\Users\memil\Downloads\Beginner Javascript\course files\playground\some-FINISHED.js
[Info  - 12:21:40 AM] Error while loading rule 'react/display-name': Cannot find module 'react' from 'C:\Users\memil\Downloads\Beginner Javascript\course files' Occurred while linting C:\Users\memil\Downloads\Beginner Javascript\course files\playground\some-FINISHED.js

After running npm install react, I get a success message, but a number of other warnings about peerdeps (sorry, didn't capture those).

Anway, after installing react, which is an odd dependency since the Beginner Javascript course doesn't - as far as I can tell - use react or even touch on it, now I have ESlint about half-way working like shown in the video (#5).

ESLint stopped working due to rule error

upgraded this package using global instructions on MD, but now ESLint has stopped working.

output on VSCode is :

 PersonalConfig » eslint-config-wesbos: 	
Configuration for rule "no-unused-vars" is invalid: 	

Value {"ignoreSiblings":true,"argsIgnorePattern":"res|next|^err"} should be equal to one of the allowed values. 	

Value {"ignoreSiblings":true,"argsIgnorePattern":"res|next|^err"} should NOT have additional properties. 	

Value {"ignoreSiblings":true,"argsIgnorePattern":"res|next|^err"} should match exactly one schema in oneOf. 

I read some threads here that this was fixed through a previous release, but donesn't seem to be working for me, any ideas?

Project dependency tree issue with react-scripts eslint version

Just tried this on a clean CRA install, and the console is throwing an error when I try to start the app.

term-output

Steps to reproduce

$ npx create-react-app new project
cd in, then...
$ npx install-peerdeps --dev eslint-config-wesbos
then there's an install using yarn prompt, go past that, successfully installed.
$ yarn start
then, WHAM!
term-output-full

Running through those instructions solves the issue, so you might want to remove eslint from the peerdeps for new installs.

Global npx install fails

Screen Shot 2019-03-09 at 10 15 29 AM

also tried and failed with reset via

npm remove --global eslint-config-wesbos babel-eslint eslint eslint-config-prettier eslint-config-airbnb eslint-plugin-html eslint-plugin-prettier eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react prettier

Eslint failed to load Wesbos with Gatsby

Hi !

I don't know why, but recently your setting doesn't work anymore with Gatsby... Outside Gatsby, the plugin still works.

This is the error I got :

ESLint: Failed to load config "wesbos" to extend from. Referenced from: /Users/$USER/.eslintrc. Please see the 'ESLint' output channel for details.

And the terminal Output

[Info  - 23:33:00] ESLint server stopped.
[Info  - 23:33:00] ESLint server running in node v10.11.0
[Info  - 23:33:00] ESLint server is running.
[Info  - 23:33:00] ESLint library loaded from: /Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/api.js
[Error - 23:33:00] ESLint stack trace:
[Error - 23:33:00] Error: Failed to load config "wesbos" to extend from.
Referenced from: /Users/$user/.eslintrc
    at configMissingError (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:233:9)
    at ConfigArrayFactory._loadExtendedShareableConfig (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:712:23)
    at ConfigArrayFactory._loadExtends (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:617:25)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:547:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:491:20)
    at _normalizeObjectConfigData.next (<anonymous>)
    at createConfigArray (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:307:25)
    at ConfigArrayFactory.loadInDirectory (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:400:16)
    at CascadingConfigArrayFactory._finalizeConfigArray (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:381:55)
[Error - 23:35:38] ESLint stack trace:
[Error - 23:35:38] Error: Failed to load config "wesbos" to extend from.
Referenced from: /Users/$user/.eslintrc
    at configMissingError (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:233:9)
    at ConfigArrayFactory._loadExtendedShareableConfig (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:712:23)
    at ConfigArrayFactory._loadExtends (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:617:25)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:547:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:491:20)
    at _normalizeObjectConfigData.next (<anonymous>)
    at createConfigArray (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:307:25)
    at ConfigArrayFactory.loadInDirectory (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/config-array-factory.js:400:16)
    at CascadingConfigArrayFactory._finalizeConfigArray (/Users/$user/working/gatsby/Diametal/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:381:55)

Typescript Beta

Okay, I've put together a beta for typescript support.

I've run it through a few projects, but likely haven't hit every issue so I'm looking for testers. Both for errors as well as suggestions on rules. It's mostly based on my own existing eslint as well as airbnb's typescript rules.

to run:

  1. In a project with package.json, run npx install-peerdeps --dev [email protected]
  2. In your package.json add this:
  "eslintConfig": {
    "extends": "wesbos/typescript.js"
  },
  1. I needed to create an empty tsconfig.json in the root for it to work.

Then the rest of the steps for VS code or CLI will work.

let me know what you think / run into!

`react/jsx-filename-extension` rule is being overridden

Hopefully, this will help someone else.
I'm building a gatsby project and have found that the rule below is not being applied.

"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],

Looks like the Airbnb rules under node_modules takes precedence.

Adding the rule to the node_modules/eslint-config-airbnb/rules/react-a11y.js file seems to have resolved the issue. Happy Days 🙃

version information:

Error when install global.

Here is the short error:

$ npx install-peerdeps --global eslint-config-wesbos
npm ERR! code ENOLOCAL
npm ERR! Could not install from "..\AppData\Roaming\npm-cache\_npx\8316" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\...\AppData\Roaming\npm-cache\_logs\2019-03-20T07_41_12_139Z-debug.log
Install for install-peerdeps@latest failed with code 1

Here is the full from debug.log

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\Steve Phuc\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'install-peerdeps@latest',
1 verbose cli   '--global',
1 verbose cli   '--prefix',
1 verbose cli   'C:\\Users\\Steve',
1 verbose cli   'Phuc\\AppData\\Roaming\\npm-cache\\_npx\\8316',
1 verbose cli   '--loglevel',
1 verbose cli   'error',
1 verbose cli   '--json' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 73c55768641db36d
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for file:Phuc\AppData\Roaming\npm-cache\_npx\8316 Could not install from "Phuc\AppData\Roaming\npm-cache\_npx\8316" as it does not contain a package.json file.
8 http fetch GET 304 https://registry.npmjs.org/install-peerdeps 412ms (from cache)
9 silly pacote tag manifest for install-peerdeps@latest fetched in 434ms
10 timing stage:rollbackFailedOptional Completed in 1ms
11 timing stage:runTopLevelLifecycles Completed in 448ms
12 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\Steve Phuc\Phuc\AppData\Roaming\npm-cache\_npx\8316\package.json'
13 verbose cwd C:\Users\Steve Phuc
14 verbose Windows_NT 10.0.17763
15 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Steve Phuc\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "install-peerdeps@latest" "--global" "--prefix" "C:\\Users\\Steve" "Phuc\\AppData\\Roaming\\npm-cache\\_npx\\8316" "--loglevel" "error" "--json"
16 verbose node v10.15.3
17 verbose npm  v6.9.0
18 error code ENOLOCAL
19 error Could not install from "Phuc\AppData\Roaming\npm-cache\_npx\8316" as it does not contain a package.json file.
20 verbose exit [ 1, true ]

also tried and failed with reset

Cannot find module 'eslint-config-wesbos' Laravel local install

I did all the local installation guide and now I get this error if I run the eslint . in terminal. But in VSCode it just formats it with another setting which I don't no where it is and it just ignores my .eslintrc file completely. However, when I run it in terminal it shows the following:

Cannot find module 'eslint-config-wesbos'
Referenced from: /home/amin/Code/prototype/prent/alpha/.eslintrc
Error: Cannot find module 'eslint-config-wesbos'
Referenced from: /home/amin/Code/prototype/prent/alpha/.eslintrc
    at ModuleResolver.resolve (/usr/local/lib/node_modules/eslint/lib/util/module-resolver.js:74:19)
    at resolve (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:471:25)
    at load (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:542:26)
    at configExtends.reduceRight (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:421:36)
    at Array.reduceRight (<anonymous>)
    at applyExtends (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:403:28)
    at loadFromDisk (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:514:22)
    at Object.load (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:550:20)
    at Config.getLocalConfigHierarchy (/usr/local/lib/node_modules/eslint/lib/config.js:228:44)
    at Config.getConfigHierarchy (/usr/local/lib/node_modules/eslint/lib/config.js:180:43)

Can't install ESlint and Prittier dependencies?

Hey, I have a a package.json file, created one with npm init. But I failed to install everything needed by the config: npx install-peerdeps --dev eslint-config-wesbos. What am I doing wrong? Thank you.
NPM ERR1

Can no longer install it in expo project

I used this plugin several times in my react native project.

But today I tired to install it in a new project. I run in my root project
npx install-peerdeps --dev eslint-config-wesbos

It seems as if you are using Yarn. Would you like to use Yarn for the installation? (y/n) y

Then nothing happens. My package.json does not have the dependencies installed.

Does anyone have a similar issue?

Add .eslintignore info to readme

I spent a lot of time trying to figure out why my VS Code refactoring and overall IntelliSense was so slow with this setup. I finally found that I had to add node_modules to .eslintignore.

Even though it's not a problem specific to this project, perhaps it could be added to the readme?

breaking changes in eslint-plugin-html

There is a bug in the current version of eslint-plugin-html included in this config.
This bug doesn't detect the presence of eslint and breaks.

Solution : Upgrade eslint version to 6.1.0 and upgrade eslint-plugin-html to 6.0.0

dependency error: "babel-eslint": "10.0.3"

Hello guys
I tried all the above and it is still not working for me. Does anyone have a solution to this issue?

Thanks

  1. After updating create-react-app,
  2. Installed npx install-peerdeps --dev eslint-config-wesbos
  3. Deleted node_modules & package-lock.json
  4. Removed entry for babel-eslint from package.json
  5. Created a .eslintrc file at the root
  6. Ran npm install
  7. Changed entry eslintConfig to "extends": "wesbos"
  8. Voila, it works

Edit: See this #17 (comment)

Originally posted by @abhijithvijayan in #17 (comment)

No luck setting up in Ubuntu 20.04

I think this is the first issue I've ever posted to GitHub. (Been writing code for a few years, now working on fundamentals to do it correctly so please be patient with me.)

I am working through the Beginner JavaScript course and I've tried several times to get this to work in VSCode. I am working in Ubuntu 20.04 because I prefer it over Windows 10, but I am not sure if that makes a difference.

On my last attempt I uninstalled ESLint and Prettier and then reinstalled and tried the process again. ESLint seems to be working based on the output and Prettier works manually, but I can't get them both to work automatically when I save the file.

For now I am going to skip this set up, but it seems like a huge help so I'd like to get it set up at some point. Thanks!

Cant get it to work - Noob help needed 25 $ TIP

I Send 25$ for a cup coffee (paypal) to the person that can fix the problem for me!

Hi,

First, your script looks very nice, but I can't get it to work. - Im a Noob :)

Btw I'm running "Ubuntu Budgie 20.04"

I have followed the "Local / Per Project Install" guide you have here a GitHub. / this youtube: https://www.youtube.com/watch?v=lHAeK8t94as&t

It gives me an NPM WARN when I install the script! - Here is the text from the console!

thomas@Dragon:~/Skrivebord/test$ npx install-peerdeps --dev eslint-config-wesbos
install-peerdeps v2.0.3
Installing peerdeps for eslint-config-wesbos@latest.
npm install [email protected] babel-eslint@^9.0.0 eslint@^6.1.0 eslint-config-airbnb@^18.0.0 eslint-config-prettier@^4.1.0 eslint-plugin-html@^5.0.3 eslint-plugin-import@^2.18.0 eslint-plugin-jsx-a11y@^6.2.3 eslint-plugin-prettier@^3.0.1 eslint-plugin-react@^7.14.2 eslint-plugin-react-hooks@^1.4.0 prettier@^1.16.4 --save-dev --registry https://registry.npmjs.org


> [email protected] postinstall /home/thomas/Skrivebord/test/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

npm WARN [email protected] No description
npm WARN [email protected] No repository field.

+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
added 259 packages from 181 contributors and audited 259 packages in 7.352s

33 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

SUCCESS eslint-config-wesbos
  and its peerDeps were installed successfully.
thomas@Dragon:~/Skrivebord/test$ 

But the problem is, I get an error when I run: "npm run lint:fix" from CLI

thomas@Dragon:~/Skrivebord/test$ npm run lint:fix

> [email protected] lint:fix /home/thomas/Skrivebord/test
> eslint . --fix

Error: Failed to load plugin 'html' declared in '.eslintrc » eslint-config-wesbos': eslint-plugin-html error: It seems that eslint is not loaded.
If you think this is a bug, please file a report at https://github.com/BenoitZugmeyer/eslint-plugin-html/issues

In the report, please include *all* those informations:

* ESLint version: 6.8.0
* ESLint path: /home/thomas/Skrivebord/test/node_modules/eslint/lib/api.js
* Plugin version: 5.0.5
* Plugin inclusion paths: /home/thomas/Skrivebord/test/node_modules/eslint-plugin-html/src/index.js, /home/thomas/Skrivebord/test/node_modules/eslint/lib/cli-engine/config-array-factory.js, /home/thomas/Skrivebord/test/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js, /home/thomas/Skrivebord/test/node_modules/eslint/lib/cli-engine/cli-engine.js, /home/thomas/Skrivebord/test/node_modules/eslint/lib/cli-engine/index.js, /home/thomas/Skrivebord/test/node_modules/eslint/lib/cli.js, /home/thomas/Skrivebord/test/node_modules/eslint/bin/eslint.js
* NodeJS version: v10.19.0
* CLI arguments: ["/usr/bin/node","/home/thomas/Skrivebord/test/node_modules/.bin/eslint",".","--fix"]
* Content of your lock file (package-lock.json or yarn.lock) or the output of `npm list`
* How did you run ESLint (via the command line? an editor plugin?)
* The following stack trace:
    at iterateESLintModules (/home/thomas/Skrivebord/test/node_modules/eslint-plugin-html/src/index.js:98:7)
    at Object.<anonymous> (/home/thomas/Skrivebord/test/node_modules/eslint-plugin-html/src/index.js:25:1)
    at Module._compile (/home/thomas/Skrivebord/test/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (/home/thomas/Skrivebord/test/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at ConfigArrayFactory._loadPlugin (/home/thomas/Skrivebord/test/node_modules/eslint/lib/cli-engine/config-array-factory.js:978:42)


      
    at iterateESLintModules (/home/thomas/Skrivebord/test/node_modules/eslint-plugin-html/src/index.js:83:11)
    at Object.<anonymous> (/home/thomas/Skrivebord/test/node_modules/eslint-plugin-html/src/index.js:25:1)
    at Module._compile (/home/thomas/Skrivebord/test/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (/home/thomas/Skrivebord/test/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at ConfigArrayFactory._loadPlugin (/home/thomas/Skrivebord/test/node_modules/eslint/lib/cli-engine/config-array-factory.js:978:42)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] lint:fix: `eslint . --fix`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] lint:fix script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/thomas/.npm/_logs/2020-08-17T16_27_44_999Z-debug.log

Here is the above log from: /home/thomas/.npm/_logs/2020-08-17T16_27_44_999Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/local/bin/npm', 'run', 'lint:fix' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prelint:fix', 'lint:fix', 'postlint:fix' ]
5 info lifecycle [email protected]~prelint:fix: [email protected]
6 info lifecycle [email protected]~lint:fix: [email protected]
7 verbose lifecycle [email protected]~lint:fix: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~lint:fix: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/thomas/Skrivebord/test/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/>
9 verbose lifecycle [email protected]~lint:fix: CWD: /home/thomas/Skrivebord/test
10 silly lifecycle [email protected]~lint:fix: Args: [ '-c', 'eslint . --fix' ]
11 silly lifecycle [email protected]~lint:fix: Returned: code: 2  signal: null
12 info lifecycle [email protected]~lint:fix: Failed to exec lint:fix script
13 verbose stack Error: [email protected] lint:fix: `eslint . --fix`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/thomas/Skrivebord/test
16 verbose Linux 5.4.0-42-generic
17 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "run" "lint:fix"
18 verbose node v10.19.0
19 verbose npm  v6.14.7
20 error code ELIFECYCLE
21 error errno 2
22 error [email protected] lint:fix: `eslint . --fix`
22 error Exit status 2
23 error Failed at the [email protected] lint:fix script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

And I have also try to run eslint --fix in VS: Code! (CTRL + SHIFT + P) I only get this error https://i.imgur.com/jGBpdWW.png

The code did not change!

I have tried to reinstall VS: Code, and disable all plugins - I have only "eslint" installed

Btw, I have tried to delete my test folder ~/Skrivebord/test and start over again

And here is another log file.

 info it worked if it ends with ok
 verbose cli [ '/usr/bin/node', '/usr/local/bin/npm', 'run', 'lint', 'fix' ]
 info using [email protected]
 info using [email protected]
 verbose run-script [ 'prelint', 'lint', 'postlint' ]
 info lifecycle [email protected]~prelint: [email protected]
 info lifecycle [email protected]~lint: [email protected]
 verbose lifecycle [email protected]~lint: unsafe-perm in lifecycle true
 verbose lifecycle [email protected]~lint: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/thomas/Skrivebord/test/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
 verbose lifecycle [email protected]~lint: CWD: /home/thomas/Skrivebord/test
 silly lifecycle [email protected]~lint: Args: [ '-c', 'eslint . "fix"' ]
 silly lifecycle [email protected]~lint: Returned: code: 2  signal: null
 info lifecycle [email protected]~lint: Failed to exec lint script
 verbose stack Error: [email protected] lint: `eslint . "fix"`
 verbose stack Exit status 2
 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
 verbose stack     at EventEmitter.emit (events.js:198:13)
 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
 verbose stack     at ChildProcess.emit (events.js:198:13)
 verbose stack     at maybeClose (internal/child_process.js:982:16)
 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
 verbose pkgid [email protected]
 verbose cwd /home/thomas/Skrivebord/test
 verbose Linux 5.4.0-42-generic
 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "run" "lint" "fix"
 verbose node v10.19.0
 verbose npm  v6.14.7
 error code ELIFECYCLE
 error errno 2
 error [email protected] lint: `eslint . "fix"`
 error Exit status 2
 error Failed at the [email protected] lint script.
 error This is probably not a problem with npm. There is likely additional logging output above.
 verbose exit [ 2, true ]

My settings files look like this:

My .eslintrc file looks like this:

{
  "extends": [
    "wesbos"
  ]
}

My package.json file looks like this:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "test.js",
  "scripts": {
  "lint": "eslint .",
  "lint:fix": "eslint . --fix"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-eslint": "^9.0.0",
    "eslint": "^6.8.0",
    "eslint-config-airbnb": "^18.2.0",
    "eslint-config-prettier": "^4.3.0",
    "eslint-config-wesbos": "0.0.20",
    "eslint-plugin-html": "^5.0.5",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-prettier": "^3.1.4",
    "eslint-plugin-react": "^7.20.6",
    "eslint-plugin-react-hooks": "^1.7.0",
    "prettier": "^1.19.1"
  }
}

My settings.json looking like this:

{
    "notebook.kernelProviderAssociations": [
    
    ]
    // These are all my auto-save configs
    "eslint.autoFixOnSave": true,
    // turn it off for JS and JSX, we will do this via eslint
    "[javascript]": {
        "editor.formatOnSave": false
    },
    "[javascriptreact]": {
        "editor.formatOnSave": false
    },
    // tell the ESLint plugin to run on save
    "editor.codeActionsOnSave": {
        "source.fixAll": true
    },
    // Optional BUT IMPORTANT: If you have the prettier extension enabled for other languages like CSS and HTML, turn it off for JS since we are doing it through Eslint already
    "prettier.disableLanguages": [
        "javascript",
        "javascriptreact"
    ],
}

My test.js I try to test with looks like this:

function sayHi ( name ) {
var age=10;
}

let age=12;

var things = ['cool'], "doubleee!!!" ];

If I run this command: npm list -g | head -n 1

thomas@Dragon:~/Skrivebord/test$ npm list -g | head -n 1
/usr/local/lib
npm ERR! peer dep missing: eslint@^5.16.0 || ^6.8.0 || ^7.2.0, required by [email protected]
npm ERR! peer dep missing: eslint@>=6.2.2, required by [email protected]
npm ERR! peer dep missing: eslint@>=5.16.0, required by [email protected]
npm ERR! peer dep missing: eslint@>=5.0.0, required by [email protected]
npm ERR! peer dep missing: eslint-plugin-import@^2.21.2, required by [email protected]
npm ERR! peer dep missing: eslint-plugin-import@>=2.18.0, required by [email protected]
npm ERR! peer dep missing: eslint@>=4.19.1, required by [email protected]
thomas@Dragon:~/Skrivebord/test$ 

^^ Maybe its the problem? But how to fix this??

Kind regards

Thomas aka Taxick

I Send 25$ for a cup coffee (paypal) to the person that can fix the problem for me!

Create React App requires Eslint v7.11.0

Wesbos installs Eslint v7.8.1, but application does not start with this error:
"The react-scripts package provided by Create React App requires a dependency: "eslint": "^7.11.0". "

Buggy when using VSCode

Hi there,

i started using your config globally with vscode. I noticed that I need to press cmd + s twice so that prettier & eslint-rules are applied.

You can see it here:
bug

I have the issue on my MacBook as well as my Windows laptop.

Custom Prettier rules are not working.

Apparently, it's only taking into account the Prettier default rules. I have the following rule in my settings.json:
{
"prettier.printWidth": 132,
}

But it's always cutting my lines at 80.

Custom Prettier options first need to be copied to avoid conflicts

Just a tip that maybe should be mentioned in the readme: if one wants to customize Prettier's behavior, you first need to copy the supplied Prettier rules and go from there:

 "prettier/prettier": [
      "error",
      {
        "trailingComma": "es5",
        "singleQuote": true,
        "printWidth": 80,
      }
    ],

or at the very least copy "singleQuote": true since any change to the prettier/prettier object will overwrite the initial settings and cause conflicts with eslint. Prettier's default is double quotes and so they'll battle each other to death over quotations if Prettier isn't told to change its mind.

Thanks for this by the way. Has never been easier.

Error: "prettier/react" has been merged into "prettier"

Hi Wes,

Looks like there is no need to explicitly call prettier/react in .eslintrc.js as prettier/react was merged into prettier in 8.0.0.

The error I am getting is this:
Error: "prettier/react" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21 Referenced from: /home/markconroy/Projects/gatsby-sites/dev-workspaces/node_modules/eslint-config-wesbos/index.js

which seems to be fixed by this PR: #77

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.