Git Product home page Git Product logo

eslint-config-motley's People

Contributors

bostrom avatar greenkeeperio-bot avatar petetnt avatar sirtawast avatar valstu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

eslint-config-motley's Issues

Add TypeScript extension rules

We probably should have TypeScript extension rules enabled, for example:

https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js

https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#i-am-using-a-rule-from-eslint-core-and-it-doesnt-work-correctly-with-typescript-code

I am using a rule from ESLint core, and it doesn't work correctly with TypeScript code

This is a pretty common thing because TypeScript adds new features that ESLint doesn't know about.

The first step is to check our list of "extension" rules here. An extension rule is simply a rule which extends the base ESLint rules to support TypeScript syntax. If you find it in there, give it a go to see if it works for you. You can configure it by disabling the base rule, and turning on the extension rule. Here's an example with the semi rule:

{
 "rules": {
   "semi": "off",
  "@typescript-eslint/semi": "error"
 }
}

If you don't find an existing extension rule, or the extension rule doesn't work for your case, then you can go ahead and check our issues. The contributing guide outlines the best way to raise an issue.

We release a new version our tooling every week. Please ensure that you check our the latest list of "extension" rules before filing an issue.

Remove "git add" from the lint-staged config

There's a new warning:

โš  Some of your tasks use git add command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.

Automatically install dependencies

motley-eslint-init should be run automatically when the package is installed.

I gave this a shot earlier using lifecycle hooks, but ended up in an infinite loop of yarn install.

Don't override `.eslintrc.js` if it already exists

Instead send the following warning:

eslintrc.js already exists; make sure that you extend motley in the config:

 module.exports = {
   extends: 'motley',
   env: {
     browser: true,
     node: true,
     jest: true,
   }
};

Create .prettierrc instead of inline options

The postinstall script now adds the--single-quote --trailing-comma all flags to the prettier command in package.json. This works well for the precommit hook, but if the developer has enabled a prettier-plugin in the editor which prettifies the files on save, those rules aren't picked up, but need to be separately specified in a .prettierrc file leading to duplication and potential WTFs.

If the postinstall script instead would create the aforementioned .prettierrc and place the rules there, the precommit hook and potential editor-plugins would read the rules from that file and everyone is ๐ŸŒž

Any problems with this?

Upgrade TS to 4.x

Hi, just tried out Vite 2 and it's not compatible with TS3 anymore. The Typescript side would need a version bump. This would not break any other setup as this is config is a one-off.

eslint-config-prettier runs prettier on every file being linted

https://typescript-eslint.io/linting/troubleshooting/performance-troubleshooting/#eslint-plugin-prettier

This plugin surfaces Prettier formatting problems at lint time, helping to ensure your code is always formatted. However this comes at a quite a large cost - in order to figure out if there is a difference, it has to do a Prettier format on every file being linted. This means that each file will be parsed twice - once by ESLint, and once by Prettier. This can add up for large codebases.

Instead of using this plugin, we recommend using Prettier's --check flag to detect if a file has not been correctly formatted.

On larger codebases, this definitely seems noticeable.

Install fails when lint-staged already exists (v10.0.1)

yarn install v1.3.2
(node:31331) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...
[2/2] โ  eslint-config-motley
[-/2] โ  waiting...
[-/2] โ  waiting...
[-/2] โ  waiting...
error /Users/.../node_modules/eslint-config-motley: Command failed.
Exit code: 1
Command: lib/postinstall.js
Arguments:
Directory: /Users/.../node_modules/eslint-config-motley
Output:
โš ๏ธ  .eslintrc.js already exists;
Make sure that it includes the following for 'eslint-config-motley'
to work as it should:

module.exports = {
  extends: 'motley',
  env: {
    browser: true,
    node: true,
    jest: true,
  }
};

โš ๏ธ  .prettierrc already exists;
Make sure that it includes the following for 'eslint-config-motley'
to work as it should:

{
  "singleQuote": true,
  "trailingComma": "all"
}
โš ๏ธ  A 'lint-staged' configuration already exists in package.json.
We won't overwrite it since it may include some of your own customizations.
We would have added the following rules, so check your configuration and modify it if needed:

{
  "*.{js,json,graphql,md,css,scss,less,ts}": [
    "prettier --write",
    "git add"
  ]
}
/Users/.../node_modules/eslint-config-motley/lib/postinstall.js:69
  return resolve();
  ^

Compile errors with plain CRA project (version 4.0.0 and React version 17.0.1)

Getting this error when creating a new project with CRA (javascript) and starting it:

image

Most likely related to these new features React 17 provided:

Because the new JSX transform will automatically import the necessary react/jsx-runtime functions, React will no longer need to be in scope when you use JSX. This might lead to unused React imports in your code.

Update dependencies again

Eslint 7.7.0 is out, the 6->7 contains some small breaking changes so it might cause some extra work.

Also bump airbnb config to 18.2.0 etc.

ESLint couldn't find the config "motley" to extend from.

This now happens with v13 at least:

Oops! Something went wrong! :(

ESLint: 7.11.0

ESLint couldn't find the config "motley" to extend from. Please check that the name of the config is correct.

The config "motley" was referenced from the config file in "/Users/Nykanen/Projects/other/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Force linting of staged files

Lint errors go unnoticed unless the developer has a linter enabled in the editor, an even then the developer can choose to ignore lint errors. Perhaps we could force linting of staged files?

  "lint-staged": {
    "*.{js,json,graphql,md,css,scss,less,ts}": [
+     "eslint --fix",
      "prettier --write",
      "git add"
    ]
  }

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.