Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@studyportals/code-style

Package Overview
Dependencies
Maintainers
13
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@studyportals/code-style

Default linting configurations for the Studyportals repositories

  • 1.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.2K
increased by8.91%
Maintainers
13
Weekly downloads
 
Created
Source

CodeStyle

The purpose of this repository is to provide standardized configuration files for the most common linters we use in Studyportals repositories. The main usage is in Super-Linter, which uses these configuration files to run the most important linters on most of our repositories.

Please send pull requests to Stefan Klokgieters or Rob van den Hout if you think you want to suggest changes.

Table of Contents

Install

You can add CodeStyle as a dependency to your project by running the following command:

npm install @studyportals/code-style --save-dev

Linters

ESLint

ESLint is a linter for JavaScript, as well as TypeScript code. It can help find and fix potential problems in your code. When you install the CodeStyle package you can simply extend from the ESLint configuration file inside it.

// package.json
"eslintConfig": {
    "extends": "./node_modules/@studyportals/code-style/.eslintrc.js",
    "parserOptions": {
        "sourceType": "module"
    }
}
Global variables

When global variables are used in different files than they we're defined in, ESLint will see it as an undefined variable. To solve this problem, you can define the global variables at the top of your file like so:

/* global var1, var2, var3 */

To avoid this you can define your project's global variables in a custom configuration.

TSLint

deprecated - ESLint can now be used instead

TSLint is a linter that is specifically meant to lint TypeScript code. When you install the CodeStyle package you can simply extend from the TSLint configuration file inside it.

// tslint.json
{
    "extends": "./node_modules/@studyportals/code-style/tslint.json"
}

StyleLint

StyleLint is our main linter for all styling related files. It can read all types of style related syntax, like SCSS, Sass, Less and SugarSS. When you install the CodeStyle package you can simply extend from the StyleLint configuration file inside it.

// .stylelintrc.json
{
    "extends": "./node_modules/@studyportals/code-style/.stylelintrc.json"
}

SCSSLint

deprecated

SCSSLint is a linter specifically meant for running against rulesets that are specific to .scss files. Generally though, we prefer to use StyleLint since it supports SCSS natively. When you install the CodeStyle package you can simply reference the SCSSLint configuration file inside it from your custom configuration.

# .scss-lint.yml
options:
  config-file: ./node_modules/@studyportals/code-style/.scss-lint.yml

PHP Code Sniffer

PHP Code Sniffer is a linter for PHP files. It can both detect and fix coding standard violations. PHP Code Sniffer can be run from the command line, where the configuration can be referenced.

phpcs-run --standard=./node_modules/@studyportals/code-style/phpcodesniffer.xml ./

PHPMD

PHPMD (or PHP Mess Detector) is a linter for PHP files. It takes a given PHP source code base and look for several potential problems within that source. When you install the CodeStyle package you can reference the PHPMD configuration file inside it.

<!-- phpmd.xml -->
<rule ref="./node_modules/@studyportals/code-style/phpmd.xml" />

Best practices

Whitelisting

Whitelisting source folders is the recommended way of specifying which files should be linted in a project. If certain file within the source folders needs to be skipped, that should be done on file level.

FAQs

Package last updated on 17 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc