Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode codeActionsOnSave ignore specific file

I'm using organizeImports on save, but there are some instances where the order matters and this causes an issue. I can't find anywhere if there's a way to simply ignore a page, either through comments within the page (ideally) or within the config settings.

Perhaps there's an extension that provides this functionality if not baked in. In any case, really appreciate any help tracking down a solution for this.

like image 283
dzm Avatar asked Dec 08 '25 10:12

dzm


2 Answers

the easiest work around is to use comments

// should be on top
import 'react-native-gesture-handler';
// rest
import { ApolloProvider } from '@apollo/client';
import { MenuProvider } from 'react-native-popup-menu';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import Toast from 'react-native-toast-message';
import { GqClient } from './src/graphql';
import Navigation from './src/navigation';
import { toastConfig } from './src/utils';

function App(): JSX.Element {
  return (
    <SafeAreaProvider>
      <ApolloProvider client={GqClient}>
        <MenuProvider>
          <Navigation />
        </MenuProvider>
        <Toast config={toastConfig} />
      </ApolloProvider>
    </SafeAreaProvider>
  );
}

export default App;
like image 67
Waqas Ali Avatar answered Dec 11 '25 01:12

Waqas Ali


If you're using ESLint (which I would highly recommend), you can use sort-imports or import/order (via eslint-plugin-import) to sort your import statements across the entire project, then ignore the rule in specific files/regions with special comments, like this:

/* eslint-disable import/order */

import * from "abcdefg";
import "cool-module";
// etc...

VSCode has a great ESLint plugin, which in combination with

"editor.codeActionsOnSave": {
    "source.fixAll.eslint": true,
},

will auto format and fix your code whenever the file is saved.

like image 31
j0hnm4r5 Avatar answered Dec 11 '25 02:12

j0hnm4r5



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!