错误:在/ Users / name / Desktop / blognewtonmcvue / store中找不到ESLint配置

问题描述

我在eslint中遇到此错误。我正在使用vue / vuex。这是我的堆栈跟踪:

> Module build Failed (from ./node_modules/eslint-loader/index.js):
> Error: No ESLint configuration found in
> /Users/name/Desktop/blognewtonmcvue/store.
>     at CascadingConfigArrayFactory._finalizeConfigArray (/Users/anme/Desktop/blognewtonmcvue/mevnexample/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:432:19)
>     at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/name/Desktop/blognewtonmcvue/mevnexample/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:271:21)
>     at CLIEngine.isPathIgnored (/Users/name/Desktop/blognewtonmcvue/mevnexample/node_modules/eslint/lib/cli-engine/cli-engine.js:951:18)
>     at CLIEngine.executeOnText (/Users/name/Desktop/blognewtonmcvue/mevnexample/node_modules/eslint/lib/cli-engine/cli-engine.js:868:38)
>     at lint (/Users/name/Desktop/blognewtonmcvue/mevnexample/node_modules/eslint-loader/index.js:278:17)
>     at transform (/Users/name/Desktop/blognewtonmcvue/mevnexample/node_modules/eslint-loader/index.js:252:18)
>     at /Users/name/Desktop/blognewtonmcvue/mevnexample/node_modules/loader-fs-cache/index.js:127:18
>     at ReadFileContext.callback (/Users/name/Desktop/blognewtonmcvue/mevnexample/node_modules/loader-fs-cache/index.js:31:14)
>     at FSReqCallback.readFileAfterOpen [as oncomplete] (node:fs:273:13)

我尝试的解决方案之一就是使用

eslint --init

然后我得到了这个文件

eslintrc.js

module.exports = {
    "env": {
        "browser": true,"es2021": true
    },"extends": [
        "eslint:recommended","plugin:vue/essential"
    ],"parserOptions": {
        "ecmaVersion": 12,"sourceType": "module"
    },"plugins": [
        "vue"
    ],"rules": {
    }
};

但是错误指向我的商店文件posts.js和store.js

post.js

import axios from "axios";
import vuex from "vuex";

const state = {
  posts: [],};

const getters = {
  allPosts: (state) => state.Posts,};

const actions = {
  //an action: makes a request,gets a response and calls a mutation
  async fetchPosts({ commit }) {
    // commit - to call the mutation
    const response = await axios.get("http://localhost:4000/posts");
    commit("setPosts",response.data);
  },async addPosts({ commit },title) {
    const response = await axios.post("http://localhost:4000/posts/add",{
      title,completed: false,});
    commit("newPost",async deletePosts({ commit },id) {
    await axios.delete(`http://localhost:4000/posts/delete/${id}`);
    commit("removePosts",id);
  },async filterPosts({ commit },e) {
    //Get selected number
    // const limit = parseInt(e.target.options[e.target.options.selectedindex].innerText);
    const limit = e.target.value;
    const response = await axios.get(`http://localhost:4000/posts`);
    commit("setPosts",async updatePosts({ commit },updatePosts) {
    const response = await axios.put(
      `http://localhost:4000/posts/update/${this.$route.params.id}`,updatePosts
    );
    console.log(response.data);
    commit("updatePosts",};

const mutations = {
  setPost: (state,posts) => (state.posts = posts),newPost: (state,posts) => state.posts.unshift(posts),removePost: (state,id) =>
    (state.posts = state.posts.filter((posts) => posts.id !== id)),updatePosts: (state,updPosts) => {
    const index = state.Posts.findindex((posts) => posts.id === updPosts.id);
    if (index !== -1) {
      state.posts.splice(index,1,updPosts);
    }
  },};

export default {
  state,getters,actions,mutations,};

//this is a boilerplate for vuex module

这是我的另一个文件。 store.js和post.js文件都在目录/映射“ store”中

store.js

import Vuex from "vuex";
import Vue from "vue";
import store from "./post";

//load Vuex
Vue.use(Vuex);

//create store
export default new Vuex.Store({
  modules: {
    post,},});

我有babel.config.js .eslintrc.js在我的项目中

解决方法

我通过此步骤解决了这个问题。

  1. npm卸载eslint(因为我的版本错误)
  2. npm install eslint@7.11.0(这样做是因为它支持es2021) 如果此步骤不起作用,请尝试从github再次克隆您的项目