У меня есть эта ошибка с 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)
Одним из решений, которые я пробовал, было использование
эслинт --инит
и затем я получил этот файл:
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", response.data);
},
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", response.data);
},
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", response.data);
},
};
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.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 в моем проекте