GithubHelp home page GithubHelp logo

adidas / js-linter-configs Goto Github PK

View Code? Open in Web Editor NEW
30.0 6.0 9.0 1.22 MB

JavaScript, TypeScript and CSS shareable linter configurations

License: MIT License

Shell 0.23% JavaScript 99.77%
eslint-config tslint-config stylelint-config lerna javascript typescript vuejs react shareable-configs linter-config

js-linter-configs's Introduction

Build

adidas linter configurations

adidas configurations for the different linting tools for JavaScript, TypeScript, CSS/LESS/SASS, etc.

The purpose of these configurations is to define a set of strict rules to validate the coding standards. The adidas standards are based on the most used by the community with some slight changes.

This repository provides configurations for the different JavaScript language versions, from ES5 (which acts as base configuration) to ES9.

These configurations can be used in any project written in JavaScript or TypeScript, it does not matter whether it is frontend or backend code.

Use cases

The main use case of this repository and their linter configuration is to check the code quality of the source code of the project.

The linter tools used to check these configurations will display errors if a rule is violated but they never modify the source code unless indicated to do so.

adidas is not responsible for the usage of this software for different purposes that the ones described above.

Requirements and dependencies

This repository contains different linter configuration which are independent packages. It means that all these packages are published independently but managed all together.

NodeJS/NPM are required to work with the repository.

Installation and running

  • In development mode (dependencies of the main package):
    npm ci
    
  • Install a specific package in production mode (installation of each configuration):
    npm install CONFIGURATION_PACKAGE_NAME[@VERSION]
    

The required dependencies of each package are listed in its own package.json file as dependency or peer dependency.

Specific instructions about how to run the linter configurations are placed in the README.md file of each package.

FAQ

Maintainers

Check the contributor list and you will be welcome if you want to contribute.

Contributing

Check out the CONTRIBUTING.md file to know how to contribute to this project.

ESLint Peer Dependencies

By default, eslint resolves dependencies in the first level of node_modules and won't go any deeper.

As a fix for this, we improved the resolution by adding require.resolve to each extends entry in our configurations so it will look for a nested module instead.

Be aware that currently there is no way to resolve either relative or absolute paths for the plugins section of ESLint:

License and Software Information

© adidas AG

adidas AG publishes this software and accompanied documentation (if any) subject to the terms of the MIT license with the aim of helping the community with our tools and libraries which we think can be also useful for other people. You will find a copy of the MIT license in the root folder of this package. All rights not explicitly granted to you under the MIT license remain the sole and exclusive property of adidas AG.

NOTICE: The software has been designed solely for the purpose of analyzing the code quality by checking the coding guidelines. The software is NOT designed, tested or verified for productive use whatsoever, nor or for any use related to high risk environments, such as health care, highly or fully autonomous driving, power plants, or other critical infrastructures or services.

If you want to contact adidas regarding the software, you can mail us at [email protected].

For further information open the adidas terms and conditions page.

License

MIT

js-linter-configs's People

Contributors

a-lba avatar guoyunhe avatar jesse-mm avatar moelders avatar recuencojones 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

js-linter-configs's Issues

Naming issues

Description of the issue observed:

  • The name of the folders of stylelint packages is incorrect.
  • The link to the CONTRIBUTING.md is not pointing to the correct path.

Other issues:

  • The package readme files could show the status of the project using badges.
  • The name of the package folders could be the same as the package itself.
    • Package eslint-config-adidas-env inside the folder eslint-config-env.

Update in certain rules in-order to reduce overwrites

Node/npm version(s): > 8

Package(s) version(s): 1.0.1

Rule name(s): no-invalid-this, no-extra-parens, radix

Requirements (package specific version, plugins, etc.): N/A

What does it provide?:
no-invalid-this rule with the current setup, triggers an error when we are using this in an arrow function inside a React class.

no-extra-parens clashes with no-mixed-operators rule with mathematical calculations.

radix rule with the current setup always expecting radix even for base 10 in parseInt where we in almost use the base 10 as default.

Does it conflict with any other rule?: N/A

Use case example:

for no-invalid-this, following code triggers an error.

handleClickFullAccount = (e: Event) => {
    e.preventDefault();
    this.setState(newState);
};

for no-extra-parens with no-mixed-operators rule, following code triggers an error

// triggers `no-mixed-operators` error
const top = window.screenTop + ( window.outerHeight - 400 ) / 2;

// triggers `no-extra-parens` error
const top = window.screenTop + (( window.outerHeight - 400 ) / 2);

for radix, the following code triggers an error

parseInt('50%');

// expected code
parseInt('50%', 10);

Missing rules default to eslint:recommended

Node/npm version(s): 10.8.0/6.2.0

Package(s) version(s): [email protected]

Rule name(s): no-var, prefer-arrow-callback, prefer-rest-params

Requirements (package specific version, plugins, etc.): N/A

What does it provide?:

Since these rules are omitted in eslint-config-adidas-es5, their defaults conflict with es5 standards.

Their values should be:

"no-var": "off",
"prefer-arrow-callback": "off",
"prefer-rest-params: "off"

Does it conflict with any other rule?: N/A

Use case example:

// .eslintrc
{
  "extends": "adidas-es5"
}
// main.js
var foo = 3; // no-var should not be an error

document.body.addEventListener(function() { // prefer-arrow-callback should not be an error
  var args = [].slice.call(arguments); // prefer-rest-args should not be an error
});

no-use-before-define and Sonar Analysis results clashes

Node/npm version(s): > 8

Package(s) version(s): 1.2.1

Rule name(s): no-use-before-define

What does it provide?: This rule checks if function/variable called before is it defined in order prevent hoisting.

Does it conflict with any other rule?: no

Use case example: Currently it is set to off, but in our SonarAnalysis results, it gives an error. Do you think we need to set this as error by default or overwrite it in our project?

add typescript-eslint support

For a project we are moving parts of it to TypeScript. The current configuration supports tslint but this module will get an deprecated (github issue, medium post) status in 2019. It would be great if there is migration path that leverages typescript-eslint setup in js-linter-configs.

The following rules we've already investigated and using them in eslint.

        // Ported from https://github.com/adidas/js-linter-configs/blob/master/packages/tslint-config-adidas/tslint.json
        "@typescript-eslint/await-thenable": 2,
        "@typescript-eslint/camelcase": [2, { "properties": "never" }],
        "@typescript-eslint/array-type": [2, "generic"],
        "@typescript-eslint/ban-ts-ignore": 2,
        "@typescript-eslint/ban-types": 0,
        "@typescript-eslint/class-name-casing": 2,
        "@typescript-eslint/func-call-spacing": [2, "never"],
        "@typescript-eslint/generic-type-naming": 2,
        "@typescript-eslint/member-ordering": [2,
            {
                "default": [
                    "public-static-field",
                    "public-instance-field",

                    "protected-static-field",
                    "protected-instance-field",

                    "private-static-field",
                    "private-instance-field",

                    "public-constructor",
                    "protected-constructor",
                    "private-constructor",

                    "public-static-method",
                    "public-instance-method",

                    "protected-static-method",
                    "protected-instance-method",

                    "private-static-method",
                    "private-instance-method"
                ]
            }
        ],
        "@typescript-eslint/no-extraneous-class": [
            2,
            {
                "allowEmpty": true,
                "allowConstructorOnly": true,
                "allowStaticOnly": false
            }
        ],
        "@typescript-eslint/no-for-in-array": 2,
        "@typescript-eslint/no-magic-numbers": 2,
        "@typescript-eslint/no-namespace": [2, {
            "allowDeclarations": true
        }],
        "@typescript-eslint/no-parameter-properties": 0,
        "@typescript-eslint/no-require-imports": 0,
        "@typescript-eslint/no-this-alias": [2, {
            "allowDestructuring": true,
            "allowedNames": ["^_this$"]
        }],
        "@typescript-eslint/no-triple-slash-reference": 0,
        "@typescript-eslint/no-unnecessary-qualifier": 2,
        "@typescript-eslint/no-unnecessary-type-assertion": 2,
        "@typescript-eslint/no-useless-constructor": 2,
        "@typescript-eslint/no-var-requires": 0,
        "@typescript-eslint/prefer-for-of": 2,
        "@typescript-eslint/prefer-function-type": 2,
        "@typescript-eslint/prefer-includes": 2,
        "@typescript-eslint/prefer-interface": 0,
        "@typescript-eslint/prefer-string-starts-ends-with": 2,
        "@typescript-eslint/promise-function-async": 0,
        "@typescript-eslint/require-array-sort-compare": 2,
        "@typescript-eslint/restrict-plus-operands": 2,
        "@typescript-eslint/unbound-method": 2,
        "@typescript-eslint/unified-signatures": 0

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.