Giter Site home page Giter Site logo

natterstefan / eslint-config-ns Goto Github PK

View Code? Open in Web Editor NEW
28.0 2.0 12.0 1.87 MB

ESLint config ready to be used in multiple projects. Based on Airbnb's code style with prettier, jest and react support.

Home Page: https://www.npmjs.com/package/eslint-config-ns

License: MIT License

JavaScript 91.31% Shell 0.81% TypeScript 7.87%
eslint eslint-config prettier prettier-config prettier-eslint stylelint stylelint-config react react-hooks jest

eslint-config-ns's Issues

Update ESLint to 6.x

Tasks & Notes

Upgrade ESLint

Especially try:

Fixes

  • Configuration for rule "react/jsx-curly-brace-presence" is invalid: Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '"never"').

feat: add eslint-plugin-unicorn

Feature Request

Add, besides the Airbnb rules, another popular set of rules from Sindre Sorhus.

Links

Example Config

/* eslint-disable global-require */
/**
 * @type {import('eslint').ESLint.Options}
 */
module.exports = {
  extends: [
    'eslint-config-ns-ts',
    // @see https://nextjs.org/docs/basic-features/eslint
    'plugin:@next/next/core-web-vitals',
    'plugin:@next/next/recommended',
    'plugin:storybook/recommended',
    // @see https://github.com/sindresorhus/eslint-plugin-unicorn
    'plugin:unicorn/recommended',
  ],
  plugins: ['graphql', 'lodash-tree-shakeable-import', 'unicorn'],
  rules: {
    'unicorn/filename-case': [
      'error',
      {
        cases: {
          camelCase: true,
          kebabCase: true,
          pascalCase: true,
        },
      },
    ],
    'unicorn/no-null': 'off',
    'unicorn/no-array-callback-reference': 'off',
    'unicorn/prefer-module': 'off',
    'unicorn/prevent-abbreviations': 'off',

    // 'consistent-return': ['error', { treatUndefinedAsUnspecified: true }],
 },
}

Command failed: git describe --abbrev=0 fatal: No annotated tags can describe

Bug Report

Relevant information

When running our eslint script in our repo using your package, I get the observed results. It is being used in our private repo that has the required versions of eslint, node, and peer dependencies.

I'm not sure if this is a babel issue or issue with this package. I created a copy of your repo to fit my org's needs and that's where I originally saw this, but I also see it using your package too. I think it has to do something with the parser. I have the new parser installed @babel/eslint-parser. So I'm not really sure what's going on here :/

Your Environment

  • Browser: _
  • Browser version: _
  • OS: MacOS 12.1
  • Package name: eslint-config-ns
  • Package version: 2.0.0

Steps to reproduce

Babel config:

/* eslint-disable */
const { serve } = require('./build-config');

module.exports = function (api) {
  const isTest = api.env('test');

  const plugins = [
    ['babel-plugin-styled-components'],
    ['@babel/plugin-proposal-class-properties'],
    ['@babel/plugin-proposal-private-methods'],
    ['lodash'],
    [
      'relay',
      {
        artifactDirectory: './src/scripts/__generated__',
        compat: true,
        schema: './build/data/schema.json'
      }
    ]
  ];

  if (serve) {
    plugins.push(['react-refresh/babel']);
  }

  return {
    presets: [
      [
        '@babel/preset-env',
        {
          targets: isTest
            ? {
                node: '12.20.2'
              }
            : {
                chrome: 57,
                // etc.
              },
          bugfixes: true,
          corejs: 2,
          useBuiltIns: 'entry'
        }
      ],
      ['@babel/preset-react'],
      ['@babel/preset-flow']
    ],
    plugins
  };
};
{
  /**
   * Overwrite or extend the default parserOptions
   */
  "parserOptions": {
    "requireConfigFile": false,
  },

  "extends": [
    "eslint-config-ns"
  ],
  "plugins": ["react", "flowtype", "jest", "import"],

  // Settings, rules, globals, etc.
  },

Observed Results

  • I get a bunch of these:
fatal: No annotated tags can describe '<SHA of HEAD>'.
However, there were unannotated tags: try --tags.

and then a bunch of these:

/Users/path/to/file.js
  0:0  error  Parsing error: /Users/path/to/config/babel.config.js: Error while loading config - Command failed: git describe --abbrev=0
fatal: No annotated tags can describe '<SHA of HEAD>'.
However, there were unannotated tags: try --tags

#### Expected Results

- Eslint runs all the rules and lints the code

feat: merge configs and maintain only eslint-config-ns

Feature Request

Ever since the introduction of the changes in #67, one can merge the packages again and ship all rules (javascript, typescript, jest, ...) in one config (preset) file. Thanks to https://www.npmjs.com/package/@rushstack/eslint-patch, this works without asking users to install eslint-plugin-react in a non-react project.

Decision

Add support for @next/eslint-plugin-next

Feature Request

Add another preset which supports next@11 applications out of the box, by adding the @next/eslint-plugin-next plugin.

See https://nextjs.org/docs/basic-features/eslint.

Basic example

module.exports = {
  extends: [
    'eslint-config-ns-ts',
    // @see https://nextjs.org/docs/basic-features/eslint
    'plugin:@next/next/recommended'
  ],
  /* ... */
}

Motivation

Add support for Next.js.

feat: add shared `tsconfig.json`

Feature Request

Every new TypeScript project comes the task of creating and maintaining a tsconfig.json. TypeScript configs can also be extended, that is what got me thinking if I should add one to my presets too.

Basic example

"extends": "eslint-config-ns/tsconfig.json"

Motivation

Create a shared tsconfig.json - and probably some presets like tsconfig.jest.jsonortsconfig.cypress.json` - which one can use easily.

Links and Todos

Example Repos

feat: ship with dependencies (eslint config and plugins) included

Feature Request

Ship with peerDependencies already.

Basic example

Motivation

Remove the need to install dependencies manually but still allow to update them if needed.

feat: add new rules or config settings

feat: add *.graphql support

Feature Request

Support using .graphql files in your project.

Basic example

/* eslint-disable global-require */
/**
 * @type {import('eslint').ESLint.Options}
 */
module.exports = {
  extends: [
    'eslint-config-ns-ts',
  ],
  plugins: ['graphql']
  overrides: [
    {
      files: ['*.graphql', '.gql'],
      rules: {
        /**
         * Graphql linting
         *
         * This plugin also lints GraphQL literal files ending on .gql or .graphql.
         * In order to do so set env to 'literal' to tell eslint to check these
         * files as well.
         */
        'graphql/template-strings': [
          'error',
          {
            env: 'apollo',
            schemaJson: require('./graphql/schema.json'),
          },
          {
            validators: [
              'FieldsOnCorrectTypeRule',
              'NoFragmentCyclesRule',
              'UniqueOperationNamesRule',
              'UniqueArgumentNamesRule',
            ],
            env: 'literal',
            schemaJson: require('./graphql/schema.json'),
          },
        ],
        'graphql/named-operations': [
          'error',
          {
            env: 'literal',
            schemaJson: require('./graphql/schema.json'),
          },
        ],
        'graphql/no-deprecated-fields': [
          'warn',
          {
            env: 'literal',
            schemaJson: require('./graphql/schema.json'),
          },
        ],
        // 'graphql/required-fields': [
        //   'error',
        //   {
        //     env: 'literal',
        //     schemaJson: require('./graphql/schema.json'),
        //     /**
        //      * ensure that we never miss adding `id` to queries, as this can
        //      * lead to nasty issues with apollo.
        //      */
        //     requiredFields: ['id'],
        //   },
        // ],
      },
    },
  ],
}

Tasks

  • define how to provide schemaJson files (1 and multiple/different ones).
  • add note that currently only @apollo/client code is tested

Notes

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.