Giter VIP home page Giter VIP logo

tslint-config-airbnb's Introduction

TSLint Config Airbnb

NPM version Downloads

A TSLint config for Airbnb JavaScript Style Guide


This package is deprecated

Migrate to eslint

  1. Remove tslint.json

  2. Remove lines from tsconfig.json if included

    "plugins": [
      {
        "name": "typescript-tslint-plugin"
      }
    ],
  1. Replace packages
$ npm uninstall tslint tslint-config-airbnb
$ npm uninstall typescript-tslint-plugin
$ npm install --dev eslint @typescript-eslint/eslint-plugin eslint-config-airbnb
$ npx install-peerdeps --dev eslint-config-airbnb
  1. Create .eslintrc.json
{
  "extends": ["airbnb"],
  "plugins": ["@typescript-eslint"],
  "parser": "@typescript-eslint/parser",
  "rules": {
    "import/no-unresolved": 0,
    "react/jsx-filename-extension": {
      "extensions": [
        ".jsx",
        ".tsx"
      ]
    }
  }
}

With webpack

{
  :
  "rules": {
    :
    "import/extensions": [".js", ".json", ".jsx", ".ts", ".tsx"],
    :
  },
  "settings": {
    "import/resolver": {
      "webpack": {
        "config": "webpack.config.js"
      }
    }
  }
  :
}
  1. if you are using Visual Studio Code, add to vscode's settings.json
{
  "[typescript]": {
    "editor.formatOnSave": false,
  },
  "eslint.autoFixOnSave": true,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    { "language": "typescript", "autoFix": true },
    { "language": "typescriptreact", "autoFix": true }
  ]
}

Installation

npm install tslint-config-airbnb --save-dev

Usage

In tslint.json:

{
  "extends": "tslint-config-airbnb"
}

Rules

Versioning

+----- Major version is synchronize with tslint's major version.
| +--- Minor version has BREAKING CHANGE and feat.
| | +- Patch version has patch.
| | |
x.x.x

License

Apache 2.0

tslint-config-airbnb's People

Contributors

azarbayejani avatar christiango avatar frankiepo avatar jamieweavis avatar johannpinson avatar noxan avatar progre avatar rsp avatar sangaman avatar sapegin avatar testerez avatar unindented 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

tslint-config-airbnb's Issues

What version of TSLint does it require?

tslint-config-airbnb with [email protected] gives many errors on screen while running linting with

{
  "extends": "tslint-config-airbnb"
}

What TSLint I should use?

I started to downgrade my tslint, I am now at @5.6.0 version and I still get many errors

TypeError: Cannot read property '1' of null
    at ObjectCurlySpacingWalker.checkSpacingInsideBraces (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/objectCurlySpacingRule.js:53:54)
    at ObjectCurlySpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/objectCurlySpacingRule.js:44:18)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNodes (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:11911:30)
    at Object.forEachChild (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:12042:21)
    at ObjectCurlySpacingWalker.SyntaxWalker.walkChildren (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:12)
    at ObjectCurlySpacingWalker.SyntaxWalker.visitCallExpression (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:54:14)
    at ObjectCurlySpacingWalker.SyntaxWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:305:22)
    at ObjectCurlySpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/objectCurlySpacingRule.js:46:36)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
TypeError: Cannot read property '0' of undefined
    at ArrayBracketSpacingWalker.validateArraySpacing (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:135:36)
    at ArrayBracketSpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:105:18)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNode (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:11902:24)
    at Object.forEachChild (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:12069:21)
    at ArrayBracketSpacingWalker.SyntaxWalker.walkChildren (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:12)
    at ArrayBracketSpacingWalker.SyntaxWalker.visitBinaryExpression (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:39:14)
    at ArrayBracketSpacingWalker.SyntaxWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:293:22)
    at ArrayBracketSpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:107:36)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
TypeError: Cannot read property '0' of undefined
    at ArrayBracketSpacingWalker.validateArraySpacing (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:135:36)
    at ArrayBracketSpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:105:18)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNode (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:11902:24)
    at Object.forEachChild (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:12037:21)
    at ArrayBracketSpacingWalker.SyntaxWalker.walkChildren (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:12)
    at ArrayBracketSpacingWalker.SyntaxWalker.visitElementAccessExpression (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:96:14)
    at ArrayBracketSpacingWalker.SyntaxWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:347:22)
    at ArrayBracketSpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:107:36)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
TypeError: Cannot read property '0' of undefined
    at ArrayBracketSpacingWalker.validateArraySpacing (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:135:36)
    at ArrayBracketSpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:105:18)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNode (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:11902:24)
    at Object.forEachChild (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:12082:21)
    at ArrayBracketSpacingWalker.SyntaxWalker.walkChildren (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:12)
    at ArrayBracketSpacingWalker.SyntaxWalker.visitConditionalExpression (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:72:14)
    at ArrayBracketSpacingWalker.SyntaxWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:323:22)
    at ArrayBracketSpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:107:36)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
TypeError: Cannot read property '0' of undefined
    at ArrayBracketSpacingWalker.validateArraySpacing (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:135:36)
    at ArrayBracketSpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:105:18)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNode (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:11902:24)
    at Object.forEachChild (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:12227:24)
    at ArrayBracketSpacingWalker.SyntaxWalker.walkChildren (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:12)
    at ArrayBracketSpacingWalker.SyntaxWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:530:22)
    at ArrayBracketSpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:107:36)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNode (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:11902:24)
TypeError: Cannot read property 'kind' of undefined
    at IndentWalker.getNodeIndent (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/terIndentRule.js:287:18)
    at IndentWalker.checkNodeIndent (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/terIndentRule.js:310:33)
    at /home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/terIndentRule.js:536:54
    at Array.forEach (<anonymous>)
    at IndentWalker.checkNodesIndent (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/terIndentRule.js:536:15)
    at IndentWalker.blockIndentationCheck (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/terIndentRule.js:413:18)
    at IndentWalker.visitClassDeclaration (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/terIndentRule.js:704:14)
    at IndentWalker.SyntaxWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:314:22)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNodes (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:11911:30)
TypeError: Cannot read property '1' of null
    at ObjectCurlySpacingWalker.checkSpacingInsideBraces (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/objectCurlySpacingRule.js:53:54)
    at ObjectCurlySpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/objectCurlySpacingRule.js:44:18)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNode (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:11902:24)
    at Object.forEachChild (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:12145:24)
    at ObjectCurlySpacingWalker.SyntaxWalker.walkChildren (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:12)
    at ObjectCurlySpacingWalker.SyntaxWalker.visitThrowStatement (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:240:14)
    at ObjectCurlySpacingWalker.SyntaxWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:494:22)
    at ObjectCurlySpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/objectCurlySpacingRule.js:46:36)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
TypeError: Cannot read property '0' of undefined
    at ArrayBracketSpacingWalker.validateArraySpacing (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:135:36)
    at ArrayBracketSpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:105:18)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNode (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:11902:24)
    at Object.forEachChild (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:12084:24)
    at ArrayBracketSpacingWalker.SyntaxWalker.walkChildren (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:12)
    at ArrayBracketSpacingWalker.SyntaxWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:530:22)
    at ArrayBracketSpacingWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/arrayBracketSpacingRule.js:107:36)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNodes (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:11911:30)
TypeError: Cannot read property 'filter' of undefined
    at IndentWalker.checkIndentInArrayOrObjectBlock (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/terIndentRule.js:593:29)
    at IndentWalker.visitObjectLiteralExpression (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/terIndentRule.js:735:14)
    at IndentWalker.SyntaxWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:449:22)
    at /home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNodes (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:11911:30)
    at Object.forEachChild (/home/foobar/workspace/web-ui/node_modules/typescript/lib/typescript.js:12029:24)
    at IndentWalker.SyntaxWalker.walkChildren (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:12)
    at IndentWalker.SyntaxWalker.visitArrayLiteralExpression (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:30:14)
    at IndentWalker.visitArrayLiteralExpression (/home/foobar/workspace/web-ui/node_modules/tslint-eslint-rules/dist/rules/terIndentRule.js:740:54)
    at IndentWalker.SyntaxWalker.visitNode (/home/foobar/workspace/web-ui/node_modules/tslint/lib/language/walker/syntaxWalker.js:284:22)

"createLanguageServiceHost" is not a function and variable name must be in camelcase or uppercase

I am getting Lint.createLanguageServiceHost warning when running with this config.

As for the variable name, Hello is a component name so we should allow uppercase.

Thanks!

Warning: Lint.createLanguageServiceHost is not a function
ERROR: src/components/Hello.tsx[6, 14]: variable name must be in camelcase or uppercase

Source:

export const Hello = (props: HelloProps) => (
    <h1>Hello from {props.compiler}
        and {props.framework}!</h1>
);

Warnings when using base configuration

When running tslint using tslint-config-aribnb using the following command:
tslint 'src/**/*.ts?(x)' tsconfig.json

and the following tsconfig.json:

{
  "extends": ["tslint-config-airbnb"]
}

I see the following warnings output:

Warning: The 'no-boolean-literal-compare' rule requires type information.
Warning: The 'strict-boolean-expressions' rule requires type information.

Error on installing using yarn.

error An unexpected error occurred: "https://registry.yarnpkg.com/tslint-config-airbnb/-/tslint-config-airbnb-5.1.0.tgz: Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?".

It may be a problem of yarn and not of this project but I'm logging it here regardless.

PascalCase

The following code currently gets flagged by variable-name:

const App = () => <div>Hello world!</div>;

The style guide discourages the use of name inference (here and here), so that kind of makes the example above (the notation I personally prefer) invalid, but not this one:

const App = function App() { return <div>Hello world!</div> };

I think the rule should be changed to this:

'variable-name': [true, 'check-format', 'allow-pascal-case']

A pure-component-specific exception would be nicer, of course, but, AFAIK, it doesn't exist.

NPM and git don't coincide?

Published version in npm is v5.1.0 yet I cannot see that in this repo. Could it be that you published it to npm but forgot to push your changes to this repo?

Use of strict-boolean-expressions

The configuration of tslint: strict-boolean-expressions currently prevents using short-circuit evaluation in assignment as per Airbnb's 15.7 no-unneeded-ternary:

This type is not allowed in the operand for the '||' operator because it is always truthy.

There's an issue palantir/tslint#3279 concerning the application of strict-boolean-expressions in different contexts that will hopefully allow excluding assignments - which would support loosening the rule to support compliance with no-unneeded-ternary.

Meanwhile there is no ideal setting, but I've currently overridden the rule to the following:

"strict-boolean-expressions": [
  true,
  "allow-null-union",
  "allow-undefined-union",
  "allow-string",
  "allow-mix"
]

It's not ideal... ๐Ÿ˜ but helps compliance with 15.7 for string building and assignment (at the cost of compliance with 15.3), while not allowing numbers prevents using array length without a comparison which seems to be the most common violation of 15.3 at the cost of excluding use of numbers in logical assignment.

I appreciate there are a lot of inconsistencies with the eslint implementation due largely to rule availability and differing coding standards - so mainly just flagging the open tslint issue and more generally interested in your thoughts?

[help wanted] arguments are not aligned

Hi,

I have a function that has arguments in this format

    default: Date.now,
    type: Date,
  },
},
  {
    collection: 'TransactionRequestAttributes',
    versionKey: false,
  },
);```

I get the error 'arguments are not aligned' in the second argument in the above method.  Is there a better way to configure the vscode formatting that complies with airbnb formatter and help in the dev workflow? Thanks for your time and help

False negative on function call parameter alignment

In 7.15 the example shows that we need to align this way:

// good
function foo(
  bar,
  baz,
  quux,
) {
  // ...
}

and forbid this way

// bad
function foo(bar,
             baz,
             quux) {
  // ...
}

However the current tslint config does not report error in this example:

function test(a: any,
              ...args: any[]) {
  console.log(a);
}

const bbs = test(123,
                 456);

And now it even accepts the following intendation, which looks weird:

const bba = test(
          body.fieldA,
          body.fieldB,
          body.fieldC,
          body.fieldD,
          () => {
            console.log(1);
          },
    );

The current version I am using is ^5.11.1

Could not find implementations for the following rules specified in the configuration

We're encountering the following warnings while using tslint-config-airbnb with the latest version of tslint:

$ ./node_modules/.bin/tslint --fix src/tasks/tslint.ts --project tsconfig.json

Could not find implementations for the following rules specified in the configuration:
    no-unused-expressions
    no-shadow-variable
$ ./node_modules/.bin/tslint --version
5.4.3

Update function name for AngularJS methods

I am trying to use this tslint config with a frontend project using AngularJS and Typescript. However, I get tslinting errors for Angular methods such as $onInit() and $postLink() because of the regex matching here

'static-method-regex': '^[a-z][\\w\\d]+$'

And looking at the AirBnB standards https://github.com/airbnb/javascript#naming-conventions there doesn't seem to be anything that would make a leading $ a problem.

no-param-reassign false positive

const myObject: {[myKey: string]: number} = {};

let myKey = '3';

if (myKey === '3') {
  myKey = '1'; // false positive. not flagged if first line is commented out
}

const myFunction = (myParam) => {
  myParam = 2; // should be the only one flagged
};

Possible fix: change "no-param-reassign": true to "no-parameter-reassignment": true in tslint.js

Temporary fix: in your tslint.json:

"no-parameter-reassignment": true,
"no-param-reassign": false // disable from tslint-config-airbnb

Versions:

"tslint": "^5.8.0",
"tslint-config-airbnb": "^5.3.0",
"tslint-eslint-rules": "^4.1.1",
"typescript": "^2.6.1"

Any chance to release a new version to npm?

I just spent some time figuring out why my linter config doesn't detect unused variables even though the rule is there, I extend tslint-config-airbnb properly and other rules seem to work.

I just realized that there was no release to npm since the unused variable rules was added.

Is there a chance you could make a quick version bump and npm publish? Thanks!

Note: According to the docs the "check-parameters" is experimental:

NOTE: this option is experimental and does not work with classes that use abstract method declarations, among other things.

but it seems to be enabled by default. So maybe it's not such a good idea to publish this at this point to npm, after all.

Support for latest version of typescript

Hi,
We all know the eslint is the future and everyone working towards it but until that support for tslint latest version(v6 & above) will be greater and much appreciated. Currently facing peer dependency warning while building the code.

npm WARN [email protected] requires a peer of tslint@^5.11.0 but none is installed. You must install peer dependencies yourself.

Cannot find module 'eslint-config-tslint-config-airbnb'

My eslint
eslint -c .eslintrc.yml ./src

I got error

Cannot find module 'eslint-config-tslint-config-airbnb'
Referenced from: /home/user/Project/lim/.eslintrc.yml
Error: Cannot find module 'eslint-config-tslint-config-airbnb'
Referenced from: /home/user/Project/lim/.eslintrc.yml
at ModuleResolver.resolve (/home/user/Project/lim/node_modules/eslint/lib/util/module-resolver.js:74:19)
at resolve (/home/user/Project/lim/node_modules/eslint/lib/config/config-file.js:479:28)
at load (/home/user/Project/lim/node_modules/eslint/lib/config/config-file.js:551:26)
at configExtends.reduceRight (/home/user/Project/lim/node_modules/eslint/lib/config/config-file.js:425:36)
at Array.reduceRight ()
at applyExtends (/home/user/Project/lim/node_modules/eslint/lib/config/config-file.js:403:26)
at loadFromDisk (/home/user/Project/lim/node_modules/eslint/lib/config/config-file.js:523:22)
at Object.load (/home/v/Project/lim/node_modules/eslint/lib/config/config-file.js:559:20)
at Config.loadSpecificConfig (/home/user/Project/lim/node_modules/eslint/lib/config.js:135:46)
at new Config (/home/user/Project/lim/node_modules/eslint/lib/config.js:101:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] lint: eslint -c .eslintrc.yml ./src
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] lint 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/user/.npm/_logs/2018-06-19T09_15_26_845Z-debug.log

Update to [email protected]

tslint-microsoft-config has released a new major version that fixes, among other things, an issue with Symbol.iterator and Symbol.asyncIterator not being supported as function names. Full release notes are here. This comment mentions that there are some breaking changes.

So, this package should update its version of tslint-microsoft-config. The question is: should it be under a major release ([email protected]) due to the breaking changes of tslint-microsoft-config?

export airbnb rules as jsRules too

Just copying the suggestion from this comment.

Feature request: i think the fix here is to actually copy the relevant (not TS-only) rules into a jsRules property to export.

Use case:

I'm trying to lint code with mixed ts and js files (it's not converted entirely yet to .ts). It'd be nice to run tslint on the entire codebase and have it apply the airbnb rules to both the .ts and .js files.

Tabs Not Respected After Update

I think this is likely a TSLint issue, but, after updating tslint-config-airbnb from 1x to 5x, all of a sudden TSLint (5.5.0) is telling me that all of my indentation should be spaces, even though my config looks like this:

{
	"extends": [
		"tslint-react",
		"tslint-config-airbnb"
	],
	"rules": {
		"indent": [true, "tabs"],
		"ter-indent": [true, "tabs"]
	}
}

I did not change version of TSLint or TSLint-react - only tslint-config-airbnb, and all of a sudden, my rules are no longer respected. Just wondering if you have any thoughts on what might cause this.

I run TSLint like so:

node_modules/.bin/tslint -c tslint.json 'src/**/*.ts*'

Semanic Version Policy

I was curious whether you take a semantic versioning approach to releasing changes to tslist-config-airbnb?

For example b421092 made an existing rule stricter, which would be a breaking change in that using version 5.2.0 on the same code base as 5.1 would cause tslint to fail.

Should we interact with tslint-config-airbnb as if any release could contain stricter rules and cause tslint to fail on previously passing code?

Code for 5.3.0beta

You have published v5.3.0beta to npm but the changes are missing in this repo.

Can you update your repository please?

"No valid rules have been specified" When Using tslint-config-airbnb

When I use tslint --init I get the following config:

{
  "defaultSeverity": "error",
  "extends": [
      "tslint:recommended"
  ],
  "jsRules": {},
  "rules": {},
  "rulesDirectory": []
}

If I use that config and run TSLint against my code I see errors, as expected. However, when I change just one line (after installing tslint-config-airbnb) :

  "extends": [
      "tslint-config-airbnb"
  ],

I get the following output when I run TSLint:

No valid rules have been specified

which suggests that the airbnb rules are not loading. Furthermore, even if I add a valid rule:

"rules": {
  "quotemark": [true, "single"]
},

I still get the same message, suggesting that it has short-circuited the whole rules-loading process.

Is there any obvious cause for this, and if not is there any way I can trigger some sort of debugging or logging to determine what's going wrong?

Support react

relates: #37

This package couldn't support airbnb React style. but, the name "tslint-config-airbnb" expects someone to support react.

idea:

  1. copy this package to tslint-config-airbnb-base
  2. create tslint-config-react
  3. import both package on here

Cannot set arrow-parens

"tslint-config-airbnb": "5.11.1"

"arrow-parens": [
  true,
  "ban-single-arg-parens"
]

results in Expected parentheses around arrow function argument having a body with curly braces.

How to change this rule in tslint.json?

Rule 16.1

I think curly covers the non-function part of 16.1 pretty well:

curly: [true, 'ignore-same-line']

Problem with ESLINT new packages

Hi,

I am trying to migrate to new eslint way package. I have followed the migrate instructions and I am getting this error when I open a ts file:

Error: .eslintrc.json:
	Configuration for rule "import/extensions" is invalid:
	Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '".js"').

I am doing something wrong?

I use Intellij Webstorm

This is my .eslintrc.json file:

{
  "extends": ["airbnb"],
  "plugins": ["@typescript-eslint"],
  "parser": "@typescript-eslint/parser",
  "rules": {
    "import/no-unresolved": 0,
    "import/extensions": [".js", ".json", ".jsx", ".ts", ".tsx"],
    "react/jsx-filename-extension": {
      "extensions": [
        ".jsx",
        ".tsx"
      ]
    }
  },
  "settings": {
    "import/resolver": {
      "webpack": {
        "config": "webpack.config.js"
      }
    }
  }
}

typescript 3

warning "tslint-config-airbnb > [email protected]" has incorrect peer dependency "typescript@^2.1.0".
warning "tslint-config-airbnb > [email protected]" has incorrect peer dependency "typescript@^2.2.0".

tsc version:

./node_modules/.bin/tsc -v
Version 3.0.1

Update tslint-microsoft-contrib

Happy to make a PR, but I didn't want to make any assumptions: is there a reason not to update tslint-microsoft-contrib? The latest version supports TypeScript 3.0, and it'd be great to kill a build warning for projects on a newer version of TypeScript.

trailing-comma rule conflicts with TypeScript 2.9

This rule causes the following conflicts in TypeScript 2.9 for this code:

// code snippet
const {
    var1,
    var2,
    var3,
    var4,
    var5,
    var6,
    var7,
    ...restProps
} = this.props;

Missing trailing comma

However, tsc will throw if comma is there.

TS1013: A rest parameter or binding pattern may not have a trailing comma.

Support

Is this config is mixture of

tslint
tslint-consistent-codestyle
tslint-eslint-rules
tslint-microsoft-contrib

?

or Do i need to config it manually ?

The 'no-boolean-literal-compare' rule requires type information

I use tslint-config-airbnb, and to pass linter, the console throw me following warning:

$  node node_modules/.bin/tslint src/**/*.ts 
Warning: The 'no-boolean-literal-compare' rule requires type information.

ERROR: src/app/app-routing.module.ts[7, 50]: Missing trailing comma
ERROR: src/app/app-routing.module.ts[10, 50]: Missing trailing comma
ERROR: src/app/app-routing.module.ts[22, 20]: Missing trailing comma
[...]
ERROR: src/app/new.component.spec.ts[11, 36]: Missing trailing comma
ERROR: src/app/new.component.spec.ts[13, 7]: Missing trailing comma
ERROR: src/app/new.component.spec.ts[22, 7]: Missing trailing comma
ERROR: src/app/new.component.ts[5, 38]: Missing trailing comma

and, when I run the --fix, happens same

$  node node_modules/.bin/tslint src/**/*.ts --fix
Warning: The 'no-boolean-literal-compare' rule requires type information.

Fixed 1 error(s) in src/app/app.component.ts
[...]
Fixed 8 error(s) in src/app/app-routing.module.ts

After fix:

$ node node_modules/.bin/tslint src/**/*.ts
Warning: The 'no-boolean-literal-compare' rule requires type information.

What could be the problem?

Thanks!

versions:

node: v9.8.0
npm: 5.7.1
tslint: 5.9.1

NPM published package contains sample/node_modules folder

Install from NPM:

$ npm install tslint-config-airbnb
$ du -h -d4
 12K	./node_modules/tslint-microsoft-contrib/tests
200K	./node_modules/tslint-microsoft-contrib/utils/implicitRoles
 48K	./node_modules/tslint-microsoft-contrib/utils/attributes
320K	./node_modules/tslint-microsoft-contrib/utils
928K	./node_modules/tslint-microsoft-contrib
252K	./node_modules/tslint-consistent-codestyle/rules
 12K	./node_modules/tslint-consistent-codestyle/src
292K	./node_modules/tslint-consistent-codestyle
 20K	./node_modules/tslib/docs
 88K	./node_modules/tslib
 76M	./node_modules/tslint-config-airbnb/sample/node_modules
 76M	./node_modules/tslint-config-airbnb/sample
 76M	./node_modules/tslint-config-airbnb
 36K	./node_modules/esutils/lib
 52K	./node_modules/esutils
 72K	./node_modules/doctrine/lib
104K	./node_modules/doctrine
224K	./node_modules/tsutils/util
 88K	./node_modules/tsutils/typeguard
348K	./node_modules/tsutils
4,0K	./node_modules/isarray/build
 20K	./node_modules/isarray
4,0K	./node_modules/tslint-eslint-rules/dist/support
484K	./node_modules/tslint-eslint-rules/dist/rules
488K	./node_modules/tslint-eslint-rules/dist
144K	./node_modules/tslint-eslint-rules/node_modules/tsutils
144K	./node_modules/tslint-eslint-rules/node_modules
704K	./node_modules/tslint-eslint-rules
 79M	./node_modules
 79M	.

Notice total size and size of node_modules/tslint-config-airbnb/sample/node_modules folder.

Install from github:

$ npm install git+ssh://[email protected]/progre/tslint-config-airbnb#5.6.0
$ du -h -d4
 12K	./node_modules/tslint-microsoft-contrib/tests
200K	./node_modules/tslint-microsoft-contrib/utils/implicitRoles
 48K	./node_modules/tslint-microsoft-contrib/utils/attributes
320K	./node_modules/tslint-microsoft-contrib/utils
928K	./node_modules/tslint-microsoft-contrib
252K	./node_modules/tslint-consistent-codestyle/rules
 12K	./node_modules/tslint-consistent-codestyle/src
292K	./node_modules/tslint-consistent-codestyle
 20K	./node_modules/tslib/docs
 88K	./node_modules/tslib
 28K	./node_modules/tslint-config-airbnb/sample
100K	./node_modules/tslint-config-airbnb
 36K	./node_modules/esutils/lib
 52K	./node_modules/esutils
 72K	./node_modules/doctrine/lib
104K	./node_modules/doctrine
224K	./node_modules/tsutils/util
 88K	./node_modules/tsutils/typeguard
348K	./node_modules/tsutils
4,0K	./node_modules/isarray/build
 20K	./node_modules/isarray
4,0K	./node_modules/tslint-eslint-rules/dist/support
484K	./node_modules/tslint-eslint-rules/dist/rules
488K	./node_modules/tslint-eslint-rules/dist
144K	./node_modules/tslint-eslint-rules/node_modules/tsutils
144K	./node_modules/tslint-eslint-rules/node_modules
704K	./node_modules/tslint-eslint-rules
2,6M	./node_modules
2,6M	.

Notice total size and no folder node_modules/tslint-config-airbnb/sample/node_modules

Typescript Interfaces error: Expected indentation of 4 spaces but found 2.

Hi! Thanks a lot for linter with airbnb style guide, I have a problem with interfaces, linter expects bigger indentation (when I have 2 spaces, it needs 4 spaces, when I fixed to 4, it's expects 6 etc.). To reproduce create multiline interface:

export interface User {
  email: string;
  photo: string;
}
...
Expected indentation of 4 spaces but found 2.
Expected indentation of 4 spaces but found 2.

P.S. the same story is with decorators @Deco('rator')

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.