Git Product home page Git Product logo

eslint-plugin-gridsome's Introduction


Gridsome

Build super fast, modern websites with Vue.js

Gridsome is a Vue-powered static site generator for building CDN-ready websites for any headless CMS, local files or APIs



This project is under active development. Any feedback or contributions would be appreciated.

Enjoy a modern development stack

Build websites with modern tools like Vue.js, webpack and Node.js. Get hot-reloading and access to any packages from npm and write CSS in your favorite preprocessor like Sass or Less with auto-prefixing.

Connect to any CMS or data source

Use any CMS or data source for content. Pull data from WordPress, Contentful, local Markdown, or any other headless CMS or APIs and access it with GraphQL in your pages and components.

PWA Offline-first architecture

Only critical HTML, CSS, and JavaScript get loaded first. The next pages are then prefetched so users can click around incredibly fast without page reloads, even when offline.

Get perfect page speed scores

Gridsome automatically optimizes your frontend to load and perform blazing fast. You get code-splitting, image optimization, lazy-loading, and almost perfect lighthouse scores out-of-the-box.

Build future ready websites

The future of the web is JavaScript, API's, and Markup - the Jamstack. Gridsome uses the power of blazing-fast static site generator, JavaScript and APIs to create stunning dynamic web experiences.

Ready for global domination

Gridsome sites are usually not connected to any database and can be hosted entirely on a global CDN. It can handle thousands to millions of hits without breaking - and no expensive server costs.

Quick start

1. Install Gridsome CLI tool

  • npm install --global @gridsome/cli
  • yarn global add @gridsome/cli
  • pnpm install --global @gridsome/cli

2. Create a Gridsome project

  1. gridsome create my-gridsome-site to create a new project
  2. cd my-gridsome-site to open the folder
  3. gridsome develop to start a local dev server at http://localhost:8080
  4. Happy coding 🎉🙌

3. Next steps

  1. Create .vue components in the ./src/pages directory to create pages
  2. Use gridsome build to generate static files in a ./dist folder

Learn more

How to Contribute

Install Node.js ^12.13.0 || ^14.0.0 || >=16.0.0 or higher and Yarn classic.

  1. Clone this repository.
  2. Create a new Gridsome project inside the ./projects folder.
  3. Enter the new project folder and run yarn install.
  4. The project will now use the local packages when you run gridsome develop.

Make sure your test project has a version number in its package.json if you use an existing project.

To use the local version of @gridsome/cli as the global command, enter the ./packages/cli folder and run npm link.

Yarn will add dependencies from your test projects to the root yarn.lock file. So you should not commit changes in that file unless you have added dependencies to any of the core packages. If you need to commit it, remove your projects from the ./projects folder temporary and run yarn install in the root folder. Yarn will then clean up the lock file with only necessary dependencies. Commit the file and move your projects back and run yarn install again to start developing.

Code of Conduct

In the interest of fostering an open and welcoming environment please read and follow our Code of Conduct.

License

Licensed under the MIT License.

Roadmap for v1.0

Visit the Gridsome Roadmap to keep track of which features we are currently working on.

eslint-plugin-gridsome's People

Contributors

chaitanya1010 avatar dependabot[bot] avatar freaktechnik avatar hacknug avatar hjvedvik avatar itsnwa avatar tyankatsu0105 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

eslint-plugin-gridsome's Issues

Improve `require-g-image-src`

Please write rule name what you want to improve: require-g-image-src

How are the rules improved?

Vue accepts passing an object directly to v-bind. It would be cool to support it besides passing props directly.

Provide 2-3 code examples that this rule should warn about:

// This should be accepted
<g-image v-bind="{ src: '' }" />

// This should be accepted or give a warning
<g-image v-bind="computed" />
<g-image v-bind="method(something)" />

// This should give an error
<g-image v-bind="{}" />

Additional context
I'm not sure if you could check the returned object from computed properties and methods. If that's possible that should be accepted as mentioned on comment.

change branch rules

Now, this repo's main branch is develop.
But I don't know about this strategy's merit.
So, I'd like to change main branch.

  1. Delete develop branch
  2. We can checkout from master branch

g-link consider attributes `href`

Please write rule name what you want to improve:
require-g-link-to

How are the rules improved?:
Gridsome's g-link can use href.

<g-link href="http://www.example.com">sample</g-link>
👇
<a href="http://www.example.com" target="_blank" rel="noopener">sample</a>

Now g-link requires to. However if it has href, should work g-link.

Provide 2-3 code examples that this rule should warn about:

// All correct
<template>
  <div>
    <g-link to="/" class="foo">link is here</g-link>
    <g-link href="http://www.example.com" class="foo">link is here</g-link>
  </div>
</template>

Additional context

feature Doesn't empty `to` in `g-link`

Please describe what the rule should do:

g-link is required 'to'.
When 'to' is not exist, display error message.

What category should the rule belong to?

  • Enforces code style
  • Warns about a potential error
  • Suggests an alternate way of doing something
  • Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

<template>
    <g-link
    class="foo"
    exact
  >
</template>

This would be correct:

<template>
  <g-link
    to="/"
    class="foo"
    exact
  >
</template>
<template>
  <g-link
    :to="to.path"
    class="foo"
    exact
  >
</template>

Additional context

Allow indent inside query blocks

Please write rule name what you want to improve: format-query-block

How are the rules improved?: Rules should allow queries to be indented one level inside their block.

Provide 2-3 code examples that this rule should warn about:
This is valid right now:

<static-query>
query {
  metadata {
    siteName
  }
}
</static-query>

This is valid NOT right now:

<static-query>
  query {
    metadata {
      siteName
    }
  }
</static-query>

Additional context
VSCode allows you to collapse/fold blocks based on indentation. If this isn't allowed, anything inside static-query or page-query will be visible.

Yarn 2 warning

I was just trying out Yarn 2 to see if there were any major issues with Gridsome and got this warning:

eslint-plugin-gridsome@npm:1.4.0 doesn't provide eslint@^5.0.0 || ^6.0.0 requested by vue-eslint-parser@npm:6.0.5

Guessing eslint should be listed either in dependencies or peerDependencies? 🤔

feature Doesn't empty `src` in `g-image`

Please describe what the rule should do:

What category should the rule belong to?

  • Enforces code style
  • Warns about a potential error
  • Suggests an alternate way of doing something
  • Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

<template>
  <g-image
  class="foo"
  width="300"
  />
</template>

This would be correct:

<template>
  <g-image
  :src="foo.bar.src"
  class="foo"
  width="300"
  />
</template>
<template>
  <g-image
  src="/path/foo.jpg"
  class="foo"
  width="300"
  />
</template>

Additional context

Problem with eslint v8 - Failed to load plugin 'gridsome'

Tell us about your environment

  • ESLint version: 8.25.0
  • eslint-plugin-�gridsome version: 1.6.2
  • Node version: 16

Please show your full configuration:

module.exports = {
  parser: 'vue-eslint-parser',
  extends: [
    'standard',
    'plugin:gridsome/recommended',
    'plugin:vue/vue3-recommended'
  ],
}

What did you do?

eslint --ext .js,.vue src/file.vue

What actually happened?

Oops! Something went wrong! :(

ESLint: 8.26.0

TypeError: Failed to load plugin 'gridsome' declared in '.eslintrc.js': Class extends value undefined is not a constructor or null
Referenced from: /home/manu/dev/project/.eslintrc.js
    at Object.<anonymous> (/home/manu/dev/project/node_modules/.pnpm/@[email protected]_wyqvi574yv7oiwfeinomdzmc3m/node_modules/@typescript-eslint/experimental-utils/dist/ts-eslint/CLIEngine.js:12:34)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/manu/dev/project/node_modules/.pnpm/@[email protected]_wyqvi574yv7oiwfeinomdzmc3m/node_modules/@typescript-eslint/experimental-utils/dist/ts-eslint/index.js:14:14)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
 ELIFECYCLE  Command failed with exit code 2.

Downgrade to v7 fixes the problem

Allow empty lines between code blocks

Please describe what the rule should do:

Right now adding an empty line between a fragment and a query results in the plugin warning you about it. I don't have a strong opinion about this but I feel like there might be no need to flag it as long as it's just one empty line between code blocks.

Do you have any examples of graphql code where they enforce the no-empty-lines style or otherwise? What do you think?

I don't have any app with lots of fragments and queries so it's not a real issue for me but I feel it could be for other users or become one once core adds support for more graphql-related stuff.

What category should the rule belong to?

  • Enforces code style
  • Warns about a potential error
  • Suggests an alternate way of doing something
  • Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

This is what the correct code looks like as of v1.4.0:

<page-query>
  fragment RankingParts on TourRanking {
    id
    rankings: data {
      rank
      nickname
      score
      badge: pin_badge_image_url
      ranking_started_at
      ranking_finished_at
    }
  }
  query($id: ID, $prevId: ID, $nextId: ID) {
    ranking: tourRanking(id: $id) {
      ...RankingParts
    }
    next: tourRanking(id: $prevId) {
      ...RankingParts
    }
    prev: tourRanking(id: $nextId) {
      ...RankingParts
    }
  }
</page-query>

This is what it could look like:

<page-query>
  fragment RankingParts on TourRanking {
    id
    rankings: data {
      rank
      nickname
      score
      badge: pin_badge_image_url
      ranking_started_at
      ranking_finished_at
    }
  }

  query($id: ID, $prevId: ID, $nextId: ID) {
    ranking: tourRanking(id: $id) {
      ...RankingParts
    }
    next: tourRanking(id: $prevId) {
      ...RankingParts
    }
    prev: tourRanking(id: $nextId) {
      ...RankingParts
    }
  }
</page-query>

Node engine version ?

Hey!

Ran yarn add eslint-plugin-gridsome --dev and got :
[email protected]: The engine "node" is incompatible with this module. Expected version "^10.13.0 || ^12.0.0 || ^14.0.0". Got "13.11.0"

Why isn't Node 13 included in engines ?

"engines": {
  "node": "^10.13.0 || ^12.0.0 || ^14.0.0"
}

Thanks!

Change node package manager

Now we use yarn.
However, npm is as fast as yarn.
In addition, npm can use command npm ci. It can install node_modules speedy on CI.
That's why I want to use npm insted of yarn.

Add support of vueIndentScriptAndStyle to format-query-block

Add support of vueIndentScriptAndStyle for <static-query> and <page-query>. This rule let you ignore the first level of indentation in <script> and <style> tags and seem not to be respected by the format-query-block rule.

What should be possible:

<static-query>
query {
  metadata {
    siteName
  }
}
</static-query>

What is enforced by the format-query-block:

<static-query>
  query {
    metadata {
      siteName
    }
  }
</static-query>

remove format-query-block rule

Please write rule name what you want to improve:
format-query-block

How are the rules improved?:
Prettier will supports custom block since v2.1.0
prettier/prettier#8023

So, this rule not necessary anymore.

Provide 2-3 code examples that this rule should warn about:

Additional context

Don't know how to add other rules to .eslintrc.js

I read the documentation and I have created my file .eslintrc.js and added the following config:

module.exports = {
    env: {
      node: true,
      es6: true
    },
    plugins: ["gridsome"],
    rules: {
      "gridsome/format-query-block": "error",
      "gridsome/require-g-image-src": "error",
      "gridsome/require-g-link-to": "error"
    },
    parser: "vue-eslint-parser"
  }

But I want to combine it with the following config:

module.exports = {
  root: true,
  env: {
    node: true,
  },
  extends: ["plugin:vue/recommended", "eslint:recommended", "@vue/prettier"],
  parserOptions: {
    parser: "@babel/eslint-parser",
  },
  rules: {
    "no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
    "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
  },
  overrides: [
    {
      files: [
        "**/__tests__/*.{j,t}s?(x)",
        "**/tests/unit/**/*.spec.{j,t}s?(x)",
      ],
      env: {
        jest: true,
      },
    },
  ],
};

First of all, can I combine both? And, if so, then what should I read, because the documentation was really small for the plugin.

g-link not recognizing ":to"

Tell us about your environment

  • ESLint version: 5.16.0
  • eslint-plugin-�gridsome version: 1.2.5
  • Node version: 10.8.0

Please show your full configuration:

const path = require('path');

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true,
  },
  extends: [
    'airbnb-base',
    'plugin:vue/recommended',
    'plugin:gridsome/recommended'
  ],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'vue/html-indent': ['error', 2],
    'vue/no-v-html': 'off'
  },
  parserOptions: {
    parser: 'babel-eslint',
  },
  settings: {
    'import/resolver': {
      alias: {
        map: [
          ['^~', path.resolve(__dirname, './src')]
        ],
        extensions: ['.js', '.vue']
      }
    }
  },
  plugins: [
    'gridsome'
  ]
};

What did you do?

<g-link
  class="post-card__link"
  v-bind:to="post.path"
>
  Link
</g-link>

What did you expect to happen?
The rule should have passed without issue.

What actually happened?

33:7  warning  Expected '<g-link>' elements to have 'v-bind:to' or 'to'     gridsome/require-g-link-to

Additional Comments
I'm setting up ESLint on a clean install of the Gridsome starter blog. Whether I do v-bind:to="" or :to="" it throws the error. I've also tried commenting out both my other configurations I'm extending (AirBnB and vue/recommended) and it still shows the error.

It only appears to work when I just use the normal to="", which isn't what I need.

fix rule use-env-prefix

Please write rule name what you want to improve:

How are the rules improved?:
filename is not match pathsForBrowserfileOption

Provide 2-3 code examples that this rule should warn about:

Additional context

Add use-env-prefix rules

Please describe what the rule should do:
This rule reports when using process.env without prefix GRIDSOME in browser.

What category should the rule belong to?

  • Enforces code style
  • Warns about a potential error
  • Suggests an alternate way of doing something
  • Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

export default {
  data () {
    return {
      items: []
    }
  },
  async mounted () {
    // error!!!!!!!!!!!!!!!!  cuz without prefix `GRIDSOME`
    const res = await axios.get(process.env.API_URL)
    this.items = res.data
  }
}

Additional context

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.